Ejemplo n.º 1
0
 public void OnActionExecuting(ActionExecutingContext filterContext)
 {
     var db = new DepartmentDb();
     var actionLog = new ActionLog
     {
         Controller = filterContext.ActionDescriptor.ControllerDescriptor.ControllerName,
         Action = filterContext.ActionDescriptor.ActionName + " Logged from Spl",
         DateTime = filterContext.HttpContext.Timestamp
     };
     db.AcionLogs.Add(actionLog);
     db.SaveChanges();
 }
        public IController CreateController(System.Web.Routing.RequestContext requestContext, string controllerName)
        {
            if (controllerName.ToLower().StartsWith("emp"))
            {
                var db         = new DepartmentDb();
                var controller = new EmployeeController(db);
                return(controller);
            }

            if (controllerName.ToLower().StartsWith("hom"))
            {
                var db         = new DepartmentDb();
                var controller = new HomeController(db);
                return(controller);
            }

            var defaultFactory = new DefaultControllerFactory();

            return(defaultFactory.CreateController(requestContext, controllerName));
        }
Ejemplo n.º 3
0
 public HomeController(DepartmentDb db)
 {
     _db = db;
 }