Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,11 @@ public ResponseEntity<?> updateStudent(@PathVariable int id, @RequestBody Studen
return new ResponseEntity<>("User not found", HttpStatus.NOT_FOUND);
}

Cohort cohort = cohortRepository.findById(studentRequest.getCohortId()).orElse(null);
if (cohort == null) {
return new ResponseEntity<>("Cohort not found", HttpStatus.NOT_FOUND);
}

Profile profile = profileRepository.findById(user.getProfile().getId()).orElse(null);
if (profile == null) {
return new ResponseEntity<>("Profile not found", HttpStatus.NOT_FOUND);
Expand Down Expand Up @@ -189,6 +194,12 @@ public ResponseEntity<?> updateStudent(@PathVariable int id, @RequestBody Studen
profile.setGithubUrl(studentRequest.getGithub_username());
}

if (cohort!=null) {
profile.setCohort(cohort);
}

profile.setCohort(cohort);


if (studentRequest.getEmail() != null) {
boolean emailExists = userRepository.existsByEmail(studentRequest.getEmail());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
@Setter
public class StudentRequest {

private int cohortId;
private String photo;
private String first_name;
private String last_name;
Expand Down
Loading