Example #1
0
        public async Task <ActionResult> ManageRightsForForum(ManageForumRoleRightsData data, string submitAction = "")
        {
            if (!this.HttpContext.Session.HasSystemActionRights() || !this.HttpContext.Session.HasSystemActionRight(ActionRights.SecurityManagement))
            {
                return(RedirectToAction("Index", "Home"));
            }

            data.AvailableRoles = await SecurityGuiHelper.GetAllRolesAsync();

            data.AvailableActionRights = await SecurityGuiHelper.GetAllActionRightsApplybleToAForumAsync();

            data.AvailableForums = await ForumGuiHelper.GetAllForumsWithSectionNamesAsync();

            switch (submitAction)
            {
            case "save":
                // save the data, then after this action, it'll reload the data and show it.
                data.LastActionResult = await SecurityManager.SaveForumActionRightsForForumRoleAsync(data.ActionRightsSet, data.RoleID, data.ForumID)
                                                ? "Save successful"
                                                : "Save failed";

                break;

            case "cancel":
                return(RedirectToAction("Index", "Home"));

            default:
                // nothin'
                break;
            }

            // postback which should simply fill in the data and show the form
            var forumActionRightRolesForForumRole = await SecurityGuiHelper.GetForumActionRightRolesForForumRoleAsync(data.RoleID, data.ForumID);

            data.ActionRightsSet = forumActionRightRolesForForumRole.Select(r => r.ActionRightID).ToList();

            return(View("~/Views/Admin/ManageRightsPerForum.cshtml", data));
        }