diff --git a/src/main/java/nl/veenm/paypoint/resource/AppointmentResource.java b/src/main/java/nl/veenm/paypoint/resource/AppointmentResource.java index 56a2971..3bd1060 100644 --- a/src/main/java/nl/veenm/paypoint/resource/AppointmentResource.java +++ b/src/main/java/nl/veenm/paypoint/resource/AppointmentResource.java @@ -37,12 +37,15 @@ public class AppointmentResource { return appointmentService.getAppointmentsByDate(start, companyId); } - @GET - @Produces(MediaType.APPLICATION_JSON) - @Path("/recent/{id}") - public Appointment getMostRecentAppointment(@PathParam("id") Long userId) { - return appointmentService.getMostRecentByUserId(userId); - } + +//TODO: Deze werkend maken + +// @GET +// @Produces(MediaType.APPLICATION_JSON) +// @Path("/recent/{id}") +// public Appointment getMostRecentAppointment(@PathParam("id") Long userId) { +// return appointmentService.getMostRecentByUserId(userId); +// } @GET @Produces(MediaType.APPLICATION_JSON) @@ -56,8 +59,7 @@ public class AppointmentResource { public Response addAppointment(Appointment appointment) { JsonNumber companyIdJson = jwt.getClaim("company_id"); Long companyId = companyIdJson.longValue(); - appointmentService.add(appointment, companyId); - return Response.ok().build(); + return Response.ok(appointmentService.add(appointment, companyId)).build(); } @DELETE @@ -70,7 +72,6 @@ public class AppointmentResource { @PUT @Consumes(MediaType.APPLICATION_JSON) public Response updateAppointment(Appointment appointment) { - appointmentService.update(appointment); - return Response.ok().build(); + return Response.ok(appointmentService.update(appointment)).build(); } } diff --git a/src/main/java/nl/veenm/paypoint/resource/CustomerResource.java b/src/main/java/nl/veenm/paypoint/resource/CustomerResource.java index a97d758..4764a88 100644 --- a/src/main/java/nl/veenm/paypoint/resource/CustomerResource.java +++ b/src/main/java/nl/veenm/paypoint/resource/CustomerResource.java @@ -28,7 +28,6 @@ public class CustomerResource { @POST @Produces(MediaType.APPLICATION_JSON) public Response addCustomer(Customer customer) { - customerService.addCustomer(customer); - return Response.ok().build(); + return Response.ok(customerService.addCustomer(customer)).build(); } } diff --git a/src/main/java/nl/veenm/paypoint/service/AppointmentService.java b/src/main/java/nl/veenm/paypoint/service/AppointmentService.java index 8dfaf75..369935a 100644 --- a/src/main/java/nl/veenm/paypoint/service/AppointmentService.java +++ b/src/main/java/nl/veenm/paypoint/service/AppointmentService.java @@ -34,11 +34,12 @@ public class AppointmentService { } @Transactional - public void add(Appointment appointment, Long companyId) { + public Appointment add(Appointment appointment, Long companyId) { Company company = companyRepository.findById(companyId); appointment.setCompany(company); appointmentRepository.persist(appointment); emailService.stuurBevestiging(appointment); + return appointment; } @Transactional @@ -59,7 +60,7 @@ public class AppointmentService { } @Transactional - public void update(Appointment appointment) { + public Appointment update(Appointment appointment) { Appointment appointmentToUpdate = appointmentRepository.findById(appointment.getId()); appointmentToUpdate.setTitle(appointment.getTitle()); appointmentToUpdate.setStartDate(appointment.getStartDate()); @@ -72,6 +73,7 @@ public class AppointmentService { appointmentToUpdate.setDurationInMinutes(appointment.getDurationInMinutes()); appointmentRepository.persist(appointmentToUpdate); emailService.stuurBewerking(appointmentToUpdate); + return appointmentToUpdate; } @Transactional diff --git a/src/main/java/nl/veenm/paypoint/service/CustomerService.java b/src/main/java/nl/veenm/paypoint/service/CustomerService.java index 187953e..04b94d1 100644 --- a/src/main/java/nl/veenm/paypoint/service/CustomerService.java +++ b/src/main/java/nl/veenm/paypoint/service/CustomerService.java @@ -28,7 +28,8 @@ public class CustomerService { } @Transactional - public void addCustomer(Customer customer) { + public Customer addCustomer(Customer customer) { customerRepository.persist(customer); + return customer; } }