public PartialViewResult AddRolePermissionReturnPartialView(int RoleID, int PermissionID) { Role role = database.Roles.Find(RoleID); Permission permission = database.Permissions.Find(PermissionID); bool rslt = false; if (!permission.Roles.Contains(role)) { rslt = _repo.AddRolePermission(RoleID, PermissionID); } if (rslt == true) { ViewBag.IsSaved = true; } role = _repo.GetRoleByID(RoleID); RoleViewModel rvm = new RoleViewModel() { RoleID = role.RoleID, RoleName = role.RoleName, RoleDescription = role.RoleDescription, IsSysAdmin = role.IsSysAdmin, assignedPermissions = role.Permissions.OrderBy(c => c.PermissionName).ToList() }; return(PartialView("_RolePermissionTable", rvm)); }