Unverified Commit 5b255a5d authored by Ankit Verma's avatar Ankit Verma Committed by GitHub
Browse files

Merge pull request #189 from Radheshhathwar/development

Added courseYear and courseName
Showing with 24 additions and 3 deletions
+24 -3
......@@ -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);
}
......
......@@ -36,6 +36,6 @@ public class DataCorrectionRequest {
private String updatedFirstName;
private String updatedLastName;
private LocalDate updatedDOB;
private String updatedCourseYear;
}
......@@ -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;
}
......@@ -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());
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment