Ejemplo n.º 1
0
 @RequestMapping(
     value = "/doctors",
     method = RequestMethod.POST,
     consumes = MediaType.APPLICATION_JSON,
     produces = MediaType.APPLICATION_JSON_UTF_8)
 public DoctorResponse createDoctor(@Valid @RequestBody DoctorRequest doctorRequest) {
   LOGGER.debug("Creating doctor...");
   Doctor doctor = new Doctor();
   saveOrUpdate(doctor, doctorRequest);
   LOGGER.debug("Created doctor: {}", doctor.getId());
   return new DoctorResponse(doctor.getId());
 }
Ejemplo n.º 2
0
 private void saveOrUpdate(Doctor doctor, DoctorRequest doctorRequest) {
   doctor.setFirstName(doctorRequest.getFirstName());
   doctor.setLastName(doctorRequest.getLastName());
   doctor.setEmail(doctorRequest.getEmail());
   doctorService.save(doctor);
 }