public PartialViewResult AddPermissionRoleReturnPartialView(int PermissionID, int RoleID) { Role role = database.Roles.Find(RoleID); Permission permission = database.Permissions.Find(PermissionID); bool rslt = false; if (!role.Permissions.Contains(permission)) { rslt = _repo.AddPermissionRole(PermissionID, RoleID); } if (rslt == true) { ViewBag.IsSaved = true; } permission = _repo.GetPermissionByID(PermissionID); PermissionViewModel pvm = new PermissionViewModel() { PermissionID = permission.PermissionID, PermissionName = permission.PermissionName, PermissionDescription = permission.PermissionDescription, assignedRoles = permission.Roles.ToList() }; return(PartialView("_PermissionRoleTable", pvm)); }