Exemplo n.º 1
0
        public override void OnException(MethodExecutionArgs args)
        {
            MethodInfo methodInfo = args.Method as MethodInfo;

            if (methodInfo != null)
            {
                Type returnType = methodInfo.ReturnType;
                if (returnType == typeof(int))
                {
                    args.FlowBehavior = FlowBehavior.Return;
                    args.ReturnValue  = -1;
                }
                else if (returnType == typeof(bool))
                {
                    args.FlowBehavior = FlowBehavior.Return;
                    args.ReturnValue  = false;
                }
                else if (returnType == typeof(ActionResult))
                {
                    args.FlowBehavior = FlowBehavior.Return;
                    if (MySession.Get("LoginUser") != null)
                    {
                        args.ReturnValue = new RedirectToRouteResult(
                            new RouteValueDictionary
                        {
                            { "action", "Index" },
                            { "controller", "Home" }
                        });
                    }
                    else
                    {
                        args.ReturnValue = new RedirectToRouteResult(
                            new RouteValueDictionary
                        {
                            { "action", "Index" },
                            { "controller", "Login" }
                        });
                    }
                }
                else if (returnType.IsClass)
                {
                    args.FlowBehavior = FlowBehavior.Return;
                    args.ReturnValue  = null;
                }
            }

            if (HttpContext.Current != null)
            {
                Helpers.Logger.Instance.LogException(args.Exception);
            }
            else
            {
                throw args.Exception;
            }

            base.OnException(args);
        }
Exemplo n.º 2
0
 public override void OnActionExecuting(ActionExecutingContext filterContext)
 {
     if (MySession.Get("LoginUser") == null)
     {
         filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary {
             { "controller", "Login" },
             { "action", "Index" }
         });
     }
 }
Exemplo n.º 3
0
 public override void OnActionExecuting(ActionExecutingContext filterContext)
 {
     if (MySession.Get("LoginUser") == null || ((LoginUser)MySession.Get("LoginUser")).UserTypeId != (int)UserType.Admin)
     {
         filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary {
             { "controller", "Home" },
             { "action", "Index" }
         });
     }
 }
Exemplo n.º 4
0
 public override void OnActionExecuting(ActionExecutingContext filterContext)
 {
     if (MySession.Get("LoginUser") != null && filterContext.ActionDescriptor.ActionName != "Logoff")
     {
         filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary {
             { "controller", "Home" },
             { "action", "Index" }
         });
     }
 }
Exemplo n.º 5
0
 public UserController()
 {
     _postsRepo = DalFactory.GetPostsRepo();
     _usersDal  = DalFactory.GetUsersRepo();
     _loginUser = (LoginUser)MySession.Get("LoginUser");
 }
Exemplo n.º 6
0
 public PostController()
 {
     _postsRepo  = DalFactory.GetPostsRepo();
     _loginUser  = (LoginUser)MySession.Get("LoginUser");
     _fileSystem = new FileSystem();
 }
Exemplo n.º 7
0
 public SettingsController()
 {
     userDAL   = DalFactory.GetUsersRepo();
     LoginUser = (LoginUser)MySession.Get("LoginUser");
 }