diff --git a/src/main/java/com/tarento/upsmf/examsAndAdmissions/controller/HallTicketController.java b/src/main/java/com/tarento/upsmf/examsAndAdmissions/controller/HallTicketController.java index 2c2e7bccb041cf46e23565ac24c34e603ed15807..8c3a197e7fa90260459a9dc9b714d4bbc5ebcc41 100644 --- a/src/main/java/com/tarento/upsmf/examsAndAdmissions/controller/HallTicketController.java +++ b/src/main/java/com/tarento/upsmf/examsAndAdmissions/controller/HallTicketController.java @@ -90,14 +90,16 @@ public class HallTicketController { @RequestParam(value = "updatedFirstName", required = false) Optional<String> updatedFirstNameOpt, @RequestParam(value = "updatedLastName", required = false) Optional<String> updatedLastNameOpt, @RequestParam(value = "updatedDOB", required = false) Optional<String> dobOpt, // Taking as string for optional handling + @RequestParam(value = "updatedCourseYear",required = false) Optional<String> courseYear, @RequestParam("proof") MultipartFile proof) throws IOException { // Convert Optional<String> to actual value or null if not present String updatedFirstName = updatedFirstNameOpt.orElse(null); String updatedLastName = updatedLastNameOpt.orElse(null); LocalDate updatedDOB = dobOpt.isPresent() ? LocalDate.parse(dobOpt.get()) : null; + String updatedCourseYear = courseYear.orElse(null); - ResponseDto responseDto = hallTicketService.requestHallTicketDataCorrection(studentId,examCycleId, updatedFirstName, updatedLastName, updatedDOB, proof); + ResponseDto responseDto = hallTicketService.requestHallTicketDataCorrection(studentId,examCycleId, updatedFirstName, updatedLastName, updatedDOB,updatedCourseYear, proof); return ResponseEntity.status(responseDto.getResponseCode().value()).body(responseDto); } diff --git a/src/main/java/com/tarento/upsmf/examsAndAdmissions/model/dto/DataCorrectionRequest.java b/src/main/java/com/tarento/upsmf/examsAndAdmissions/model/dto/DataCorrectionRequest.java index 0eecb6a7f293e4932864fe49501f42d97b5b578d..4eb8a1c2fc57248c1315705a7f984d9d15953ff9 100644 --- a/src/main/java/com/tarento/upsmf/examsAndAdmissions/model/dto/DataCorrectionRequest.java +++ b/src/main/java/com/tarento/upsmf/examsAndAdmissions/model/dto/DataCorrectionRequest.java @@ -36,6 +36,6 @@ public class DataCorrectionRequest { private String updatedFirstName; private String updatedLastName; private LocalDate updatedDOB; - + private String updatedCourseYear; } diff --git a/src/main/java/com/tarento/upsmf/examsAndAdmissions/model/dto/DataCorrectionRequestDto.java b/src/main/java/com/tarento/upsmf/examsAndAdmissions/model/dto/DataCorrectionRequestDto.java index 784c4616afced4c0d2aea7af2c626f6fb97e5281..a240c1a19173fc26731466f33f2df2c2157066be 100644 --- a/src/main/java/com/tarento/upsmf/examsAndAdmissions/model/dto/DataCorrectionRequestDto.java +++ b/src/main/java/com/tarento/upsmf/examsAndAdmissions/model/dto/DataCorrectionRequestDto.java @@ -15,6 +15,7 @@ public class DataCorrectionRequestDto { private String updatedFirstName; private String updatedLastName; private LocalDate updatedDOB; + private String updatedCourseYear; private String status; private String proofAttachmentPath; } diff --git a/src/main/java/com/tarento/upsmf/examsAndAdmissions/service/HallTicketService.java b/src/main/java/com/tarento/upsmf/examsAndAdmissions/service/HallTicketService.java index 9abeb5bc533cf71469100a045abb472388060799..f3fca275dab984234024bf734c8944261b5b9ce9 100644 --- a/src/main/java/com/tarento/upsmf/examsAndAdmissions/service/HallTicketService.java +++ b/src/main/java/com/tarento/upsmf/examsAndAdmissions/service/HallTicketService.java @@ -53,6 +53,8 @@ public class HallTicketService { @Autowired DataCorrectionRequestRepository dataCorrectionRequestRepository; @Autowired + CourseRepository courseRepository; + @Autowired private StudentRepository studentRepository; @Autowired private ExamCycleRepository examCycleRepository; @@ -263,6 +265,7 @@ public class HallTicketService { String updatedFirstName, String updatedLastName, LocalDate updatedDOB, + String updatedCourseYear, @RequestParam("file") MultipartFile proof) throws IOException { ResponseDto response = new ResponseDto(Constants.API_HALLTICKET_REQUEST_DATA_CORRECTION); @@ -296,6 +299,9 @@ public class HallTicketService { if (updatedDOB != null) { request.setUpdatedDOB(updatedDOB); } + if (updatedCourseYear != null){ + request.setUpdatedCourseYear(updatedCourseYear); + } request.setExamCycle(optionalExamCycle.get()); request.setStatus("NEW"); @@ -320,6 +326,7 @@ public class HallTicketService { dto.setUpdatedFirstName(request.getUpdatedFirstName()); dto.setUpdatedLastName(request.getUpdatedLastName()); dto.setUpdatedDOB(request.getUpdatedDOB()); + dto.setUpdatedCourseYear(request.getUpdatedCourseYear()); dto.setStatus(request.getStatus()); dto.setProofAttachmentPath(request.getProofAttachmentPath()); return dto; @@ -346,13 +353,16 @@ public class HallTicketService { formattedRequest.put("firstName", request.getUpdatedFirstName()); formattedRequest.put("lastName", request.getUpdatedLastName()); formattedRequest.put("dob", request.getUpdatedDOB()); + formattedRequest.put("courseYear",request.getUpdatedCourseYear()); if (request.getStudent() != null) { Student student = request.getStudent(); formattedRequest.put("prevFirstName", student.getFirstName()); formattedRequest.put("prevLastName", student.getSurname()); // changed from 'surName' formattedRequest.put("prevDob", student.getDateOfBirth()); + formattedRequest.put("preCourseYear", student.getCourse().getCourseYear()); formattedRequest.put("enrollmentNumber", student.getEnrollmentNumber()); + formattedRequest.put("courseName", student.getCourse().getCourseName()); if (Objects.equals(request.getUpdatedFirstName(), student.getFirstName())){ formattedRequest.put("firstNameFlag",FALSE); } @@ -371,6 +381,12 @@ public class HallTicketService { else { formattedRequest.put("dobFlag",TRUE); } + if (Objects.equals(request.getUpdatedCourseYear(), student.getCourse().getCourseYear())){ + formattedRequest.put("courseYearFlag",FALSE); + } + else { + formattedRequest.put("courseYearFlag",TRUE); + } List<StudentExamRegistration> registration = studentExamRegistrationRepository.getByExamCycleIdAndStudentId(request.getExamCycle().getId(), request.getStudent().getId()); if (!registration.isEmpty()) { @@ -437,8 +453,10 @@ public class HallTicketService { student.setFirstName(request.getUpdatedFirstName()); student.setSurname(request.getUpdatedLastName()); student.setDateOfBirth(request.getUpdatedDOB()); + Course course = request.getStudent().getCourse(); + course.setCourseYear(request.getUpdatedCourseYear()); studentRepository.save(student); - + courseRepository.save(course); // 2. Regenerate the hall ticket with the updated details // Optional<StudentExamRegistration> registrationOptional = Optional.ofNullable(studentExamRegistrationRepository.findByStudent(student)); List<StudentExamRegistration> registrationOptional = studentExamRegistrationRepository.getByStudentId(student.getId());