correction id coach bug
This commit is contained in:
@@ -43,11 +43,8 @@ public class SessionResource {
|
||||
@PreAuthorize("hasRole('coach')")
|
||||
public ResponseEntity<?> create(@RequestBody SessionDTO dto) {
|
||||
try {
|
||||
System.out.println("ALLEZ ZYWOO TOP 1");
|
||||
Session session = maptoEntity(dto);
|
||||
System.out.println("ID COACH: " + dto.getCoachId());
|
||||
Coach c = coachDAO.findById(dto.getCoachId()).orElse(null);
|
||||
System.out.println("IS COACH FOUND ? " + (c != null));
|
||||
session.setCoach(c);
|
||||
sessionDAO.save(session);
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(maptoDTO(session));
|
||||
@@ -149,22 +146,7 @@ public class SessionResource {
|
||||
session.setCreneau(dto.getCreneau());
|
||||
session.setDuree(dto.getDuree());
|
||||
session.setGroupe(dto.getGroupe());
|
||||
// Coach
|
||||
if (dto.getCoachId() != null) {
|
||||
Coach coach = new Coach();
|
||||
coach.setId(dto.getCoachId());
|
||||
session.setCoach(coach);
|
||||
}
|
||||
// Athletes
|
||||
if (dto.getAthleteIds() != null) {
|
||||
List<Athlete> athletes = athleteDAO.findAllById(dto.getAthleteIds());
|
||||
session.setAthletes(athletes);
|
||||
}
|
||||
// Activites
|
||||
if (dto.getActiviteIds() != null) {
|
||||
List<Activite> activites = activiteDAO.findAllById(dto.getActiviteIds());
|
||||
session.setActivites(activites);
|
||||
}
|
||||
|
||||
return session;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user