示例#1
0
        public ActionResult AdminPagesEdit(int id)
        {
            BackEndAdminPagesEdit backEndAdminPagesEdit = new BackEndAdminPagesEdit();

            AdminPages adminPages = new AdminPages();
            AdminPage  adminPage  = adminPages.GetPageByPageId(id);

            if (adminPage.IsNotNull())
            {
                backEndAdminPagesEdit.PageId            = adminPage.PageId;
                backEndAdminPagesEdit.PageParentId      = adminPage.PageParentId;
                backEndAdminPagesEdit.PageName          = adminPage.PageName;
                backEndAdminPagesEdit.Target            = adminPage.Target;
                backEndAdminPagesEdit.Url               = adminPage.Url;
                backEndAdminPagesEdit.ShowInMenu        = adminPage.ShowInMenu;
                backEndAdminPagesEdit.IsActive          = adminPage.IsActive;
                backEndAdminPagesEdit.CssClass          = adminPage.CssClass;
                backEndAdminPagesEdit.GroupsPermissions = adminPage.GroupsPermissions;
            }
            else
            {
                ModelState.AddResult(ViewData, ModelStateResult.Error, Resources.Strings.ItemDoesNotExist);
                ViewData.IsFormVisible(false);
            }

            return(View(backEndAdminPagesEdit));
        }
示例#2
0
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            string controller = filterContext.ActionDescriptor.ControllerDescriptor.ControllerName.ToLower();
            string action     = filterContext.ActionDescriptor.ActionName;

            if (BackEndSessions.CurrentUser.IsNull())
            {
                if (!(controller == "admin" && action.ToLower() == "login"))
                {
                    filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new { action = "Login", controller = "Admin", ReturnUrl = HttpUtility.UrlEncode(filterContext.HttpContext.Request.Url.AbsoluteUri) }));
                }
            }
            else
            {
                AdminPages backEndPages = new AdminPages();
                AdminPage  backEndPage  = backEndPages.GetPageByAction(action);
                if (backEndPage.IsNotNull())
                {
                    if (backEndPages.IsPermissionGranted(backEndPage.PageId, PermissionCode.Browse))
                    {
                        if (controller == "admin" && action.ToLower() == "login")
                        {
                            filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new { action = "Index", controller = "Admin" }));
                        }
                    }
                    else
                    {
                        filterContext.Result = new RedirectToRouteResult(
                            new RouteValueDictionary(
                                new
                        {
                            action       = "ErrorPage",
                            controller   = "Admin",
                            errorPage    = action,
                            errorMessage = Resources.Strings.PageAccessNotAuthorized
                        }
                                )
                            );
                    }
                }
                else
                {
                    filterContext.Result = new RedirectToRouteResult(
                        new RouteValueDictionary(
                            new
                    {
                        action       = "ErrorPage",
                        controller   = "Admin",
                        errorPage    = action,
                        errorMessage = Resources.Strings.Error404
                    }
                            )
                        );
                }
            }
        }