Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @PostMapping("/{id}")
- fun update(@PathVariable("id") id: Long, @RequestBody form: ReservationChangeForm) {
- val optional = reservationsRepository.findById(id)
- if (!optional.isPresent) {
- ErrorMessages.RESERVATION_NOT_FOUND.response()
- }
- val reservation = optional.get()
- when (form.status) {
- ACCEPTED -> reservation.accept()
- CANCELLED -> reservation.cancel()
- REJECTED -> reservation.reject()
- PENDING -> ErrorMessages.RESERVATION_STATUS_NOT_PERMITED.response()
- }
- reservationsRepository.save(reservation)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement