public User DeleteUserFromRole(int userId, int roleId) { IRoleRepository<User, Role, RolePermission> roleRepository = new EntityRoleRepository(); User user = GetUser(userId); Role role = roleRepository.FindRole(roleId); if (user == null) throw new NullUserException("User is null."); if (role == null) throw new NullRoleException("Role is null."); UserRole userRole = GetUserRole(user, role); theEntities.DeleteObject(userRole); theEntities.SaveChanges(); return user; }
private UserRole AddUserToNotConfirmedUserRole(User aUser, string aNotConfirmedRoleName) { IRoleRepository<User, Role, RolePermission> roleRepository = new EntityRoleRepository(); Role notConfirmedUserRole = roleRepository.GetRoleByName(aNotConfirmedRoleName); return AddUserToRole(aUser, notConfirmedUserRole); }