Beispiel #1
0
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            var permisstion = new Models.Login().GetPermission();

            var allow = false;

            if (permisstion != null && permisstion.Account != null)
            {
                if (filterContext.ActionDescriptor.ActionName.ToLower().Equals("index"))
                {
                    allow = permisstion.IsAllow(Models.eAction.Search, GetFea());
                }
                else if (filterContext.ActionDescriptor.ActionName.ToLower().Equals("delete"))
                {
                    allow = permisstion.IsAllow(Models.eAction.Delete, GetFea());
                }
                else if (filterContext.ActionDescriptor.ActionName.ToLower().Equals("create"))
                {
                    allow = permisstion.IsAllow(Models.eAction.Add, GetFea());
                }
                else if (filterContext.ActionDescriptor.ActionName.ToLower().Equals("edit"))
                {
                    allow = permisstion.IsAllow(Models.eAction.Edit, GetFea());
                    if (!allow)
                    {
                        allow = GetFea() == Models.eFea.QLTK && filterContext.ActionParameters["id"] != null && filterContext.ActionParameters["id"].ToString().Equals(permisstion.Account.UserId.ToString());
                    }
                }
                else
                {
                    allow = true;
                }
            }
            if (!allow)
            {
                filterContext.Result = new RedirectToRouteResult(
                    new RouteValueDictionary(new
                {
                    controller = "Login",
                    action     = "Index"
                }));
            }
            base.OnActionExecuting(filterContext);
        }
Beispiel #2
0
        // GET: Menu
        public ActionResult Redirect(string sAction, Models.eFea Fea)
        {
            var    per = new Models.Login().GetPermission();
            string action = "", controller = "";

            Models.eAction _acction = (Models.eAction)Enum.Parse(typeof(Models.eAction), sAction);
            if (per.IsAllow(_acction, Fea))
            {
                switch (Fea)
                {
                case WEB_QLGD01.Models.eFea.QLCG:
                    controller = "Expert";
                    break;

                case WEB_QLGD01.Models.eFea.QLCH:
                    controller = "ShiftDay";
                    break;

                case WEB_QLGD01.Models.eFea.QLCTGV:
                    controller = "ExpertsDetailt";
                    break;

                case WEB_QLGD01.Models.eFea.QLCTHV:
                    controller = "StudentDetail";
                    break;

                case WEB_QLGD01.Models.eFea.QLHV:
                    controller = "Student";
                    break;

                case WEB_QLGD01.Models.eFea.QLKH:
                    controller = "Courses";
                    break;

                case WEB_QLGD01.Models.eFea.QLLGD:
                    controller = "Home";
                    break;

                case WEB_QLGD01.Models.eFea.QLNKGD:
                    controller = "CoursesJournal";
                    break;

                case WEB_QLGD01.Models.eFea.QLTTT:
                    controller = "Weekday";
                    break;

                case WEB_QLGD01.Models.eFea.QLTK:
                    controller = "Account";
                    break;

                case WEB_QLGD01.Models.eFea.QLPQ:
                    controller = "Permission";
                    break;

                case WEB_QLGD01.Models.eFea.QLVT:
                    controller = "Role";
                    break;

                case WEB_QLGD01.Models.eFea.QLHVV:
                    controller = "CoursesStudentDetailt";
                    break;

                default:
                    controller = "Error";
                    break;
                }
                switch (_acction)
                {
                case WEB_QLGD01.Models.eAction.Delete:
                    action = "Delete";
                    break;

                case WEB_QLGD01.Models.eAction.Add:
                    action = "Create";
                    break;

                case WEB_QLGD01.Models.eAction.Edit:
                    action = "Edit";
                    break;

                case WEB_QLGD01.Models.eAction.Search:
                    action = "Index";
                    break;

                default:
                    action = "Index";
                    break;
                }
            }
            return(RedirectToAction(action, controller));
        }