[master] Encapsulated logic to BaseController.cs.