public ActionResult ActionsInRole(string roleId, int systemId) { ViewBag.SystemId = systemId; roleId.ThrowIfNull("roleId"); var role = this.roleService.Get(PredicateBuilder.True <SYS_Role>().And(r => r.SystemRoleId == roleId)); var assignedActionList = this.roleService.GetActionsInRole(roleId); var where = PredicateBuilder.True <SYS_Action>(); where = where.And(c => c.SystemId == systemId); var actionList = this.actionService.GetMenuList(where); MenuHelper.UpdateMenuName(actionList); var viewList = actionList.Select(a => new RoleActionsModel { ActionId = a.ActionId, ActionName = a.ActionName, IconClass = a.IconClass, ParentId = a.ParentId, IsAssigned = assignedActionList.Any(aa => aa.ActionId == a.ActionId), Url = a.Url }); ViewBag.RoleName = role.RoleName; ViewBag.RoleId = roleId; var actionPerms = actionService.GetActionPerms(); ViewData["ActionPerms"] = actionPerms; var pList = permissionRepository.ToList(p => p.SystemId == systemId); var permCodes = pList.Select(c => new KeyValuePair <int, string>(c.PermCode, c.PermName)).ToList(); ViewData["PermCodes"] = permCodes; if (!string.IsNullOrEmpty(role.Permissions)) { var perms = role.Permissions.Split('|'); var rolePerms = ""; foreach (var perm in perms) { if (!string.IsNullOrEmpty(perm)) { var type = perm.Split('#')[0]; if (int.Parse(type) == systemId) { rolePerms = perm.Split('#')[1]; } } } ViewData["RolePerms"] = rolePerms; } return(View(viewList)); }
public ActionResult PermModify(string menuId) { var menu = actionService.Get(m => m.ActionId == menuId); var pList = permissionRepository.ToList(p => p.SystemId == menu.SystemId); var url = menu.Url; if (url.Count(c => c == '/') > 2) { url = url.TrimStart('/'); url = url.Substring(url.IndexOf("/"), url.Length - url.IndexOf("/")); } var controller = url.Count(c => c == '/') == 2 ? url.Substring(url.IndexOf("/") + 1, url.TrimStart('/').IndexOf("/")) : url.Substring(url.IndexOf("/") + 1, url.Length - 1); var permCodes = pList.Where(c => c.Controller == controller).Select(c => new KeyValuePair <int, string>(c.PermCode, c.PermName)).ToList(); var oldPermCodes = actionService.GetActionPerms(menuId); ViewData["PermCodes"] = permCodes; ViewData["MenuId"] = menuId; ViewData["OldPermCodes"] = oldPermCodes; ViewData["OtherPermCodes"] = pList.Where(c => c.Controller != controller).OrderBy(c => c.Controller).ToList(); return(View()); }