public ActionResult PostRightsManagement(string roleValue, string selectedList) { UserMenuResponse userMenuRights = menuRightsService.SaveRoleMenuRight(roleValue, selectedList, RoleManager.FindById(roleValue)); RightsManagementViewModel viewModel = new RightsManagementViewModel(); viewModel.Roles = userMenuRights.Roles.ToList(); viewModel.Rights = userMenuRights.Menus.Select( m => new Rights { MenuId = m.MenuId, MenuTitle = m.MenuTitle, IsParent = m.IsRootItem, IsSelected = userMenuRights.MenuRights.Any(menu => menu.Menu.MenuId == m.MenuId), ParentId = m.ParentItem != null ? m.ParentItem.MenuId : (int?)null }).ToList(); viewModel.SelectedRoleId = roleValue; TempData["message"] = new MessageViewModel { Message = "Record has been updated.", IsUpdated = true }; return(RedirectToAction("RightsManagement")); }
public void Post(RightsManagementRequest request) { if (request == null || string.IsNullOrEmpty(request.RoleId)) { throw new HttpException((int)HttpStatusCode.BadRequest, "Invalid Request"); } HttpContext.Current.Session["Menu"] = null; menuRightsService.SaveRoleMenuRight(request.RoleId, request.SelectedMenuIds, null); }
public ActionResult PostRightsManagement(string roleValue, string selectedList) { UserMenuResponse userMenuRights = menuRightsService.SaveRoleMenuRight(roleValue, selectedList, RoleManager.FindById(roleValue)); RightsManagementViewModel viewModel = new RightsManagementViewModel(); viewModel.Roles = userMenuRights.Roles.ToList(); viewModel.Rights = userMenuRights.Menus.Select( m => new MenuRightModel { MenuId = m.MenuId, MenuTitle = m.MenuTitle, IsParent = m.IsRootItem, IsSelected = userMenuRights.MenuRights.Any(menu => menu.Menu.MenuId == m.MenuId), //ParentId = m.ParentItem != null ? m.ParentItem.MenuId : (int?)null }).ToList(); viewModel.SelectedRoleId = roleValue; return(View("RightsManagement", viewModel)); }