Merge remote-tracking branch 'refs/remotes/origin/main'
This commit is contained in:
@@ -44,11 +44,11 @@ public class SessionResource {
|
||||
@PreAuthorize("hasRole('coach')")
|
||||
public ResponseEntity<?> create(@RequestBody SessionDTO dto) {
|
||||
try {
|
||||
Session session = maptoEntity(dto);
|
||||
if(sessionDAO.findById(session.getId()).isPresent()) {
|
||||
return ResponseEntity.status(HttpStatus.OK).body("Session with ID " + session.getId() + " already exists.");
|
||||
if(sessionDAO.findById(dto.getId()).isPresent()) {
|
||||
return ResponseEntity.status(HttpStatus.OK).body("Session with ID " + dto.getId() + " already exists.");
|
||||
|
||||
}
|
||||
Session session = maptoEntity(dto);
|
||||
Coach c = coachDAO.findById(dto.getCoachId()).orElse(null);
|
||||
session.setCoach(c);
|
||||
sessionDAO.save(session);
|
||||
@@ -161,7 +161,7 @@ public class SessionResource {
|
||||
|
||||
private Session maptoEntity(SessionDTO dto) {
|
||||
Session session = new Session();
|
||||
System.out.println("ID "+ dto.getId());
|
||||
System.out.println("ID "+ session.getId());
|
||||
session.setName(dto.getName());
|
||||
session.setIsRecurrent(dto.getIsRecurrent());
|
||||
session.setCreneau(dto.getCreneau());
|
||||
|
||||
Reference in New Issue
Block a user