public Team save(Team team) { Team result; User principal; principal = userService.findByPrincipal(); result = teamRepository.save(team); if (team.getId() == 0) { principal.getTeamsCreated().add(result); principal.getTeams().add(result); } userService.save(principal); return result; }
public void delete(Team team) { User captain; captain = team.getCaptain(); for (Tournament t : team.getTournaments()) { Assert.isTrue(t.getFinishMoment().before(new Date())); } captain.getTeams().remove(team); captain.getTeamsCreated().remove(team); Assert.notNull(team); checkPrincipal(team); teamRepository.delete(team); userService.save(captain); }