public IResult addRoleToUser(int roleId, int userId) { var isExistUser = _user.getOne(x => x.Id == userId); if (isExistUser == null) { return(new ErrorResult()); } var isExistRole = _role.getOne(x => x.Id == roleId); if (isExistRole == null) { return(new ErrorResult()); } var isExistRoleToUser = _role.getOne(x => x.userRoles.Any(y => y.roleId == roleId && y.userId == userId)); if (isExistRoleToUser != null) { return(new ErrorResult()); } _role.addRoleToUser(roleId, userId); return(new SuccessResult()); }
public roles getOne(int id) { return(_roleDal.getOne(x => x.id == id)); }