Advertisement
folfix

akceptacje rezerwacji

Jun 20th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 0.63 KB | None | 0 0
  1.     @PostMapping("/{id}")
  2.     fun update(@PathVariable("id") id: Long, @RequestBody form: ReservationChangeForm) {
  3.         val optional = reservationsRepository.findById(id)
  4.  
  5.         if (!optional.isPresent) {
  6.             ErrorMessages.RESERVATION_NOT_FOUND.response()
  7.         }
  8.  
  9.         val reservation = optional.get()
  10.         when (form.status) {
  11.             ACCEPTED -> reservation.accept()
  12.             CANCELLED -> reservation.cancel()
  13.             REJECTED -> reservation.reject()
  14.             PENDING -> ErrorMessages.RESERVATION_STATUS_NOT_PERMITED.response()
  15.         }
  16.         reservationsRepository.save(reservation)
  17.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement