Example #1
0
 public Team updateTeam(Team team) {
   if (team.getId() != null) {
     return teamRepository.save(team);
   } else {
     throw new TeamNotFoundException(
         "Team not found. Team doesn't have an ID. Please use create method!");
   }
 }
Example #2
0
 public void addUserToTeam(User user, Team team) {
   if (userService.findByTeamId(team.getId()).size() < 10) {
     if (user.getTeam() == null) {
       user.setTeam(team);
       userRepository.save(user);
     } else {
       throw new UserAlreadyInTeamException("This user is already in a team");
     }
   } else {
     throw new TeamIsFullException("Team is full, already contains 10 members!");
   }
 }