diff --git a/src/main/java/alfio/controller/api/v2/user/ReservationApiV2Controller.java b/src/main/java/alfio/controller/api/v2/user/ReservationApiV2Controller.java index 9352adb739..e12dd189cd 100644 --- a/src/main/java/alfio/controller/api/v2/user/ReservationApiV2Controller.java +++ b/src/main/java/alfio/controller/api/v2/user/ReservationApiV2Controller.java @@ -18,7 +18,9 @@ import alfio.controller.ReservationController; import alfio.controller.form.ContactAndTicketsForm; +import alfio.controller.support.SessionUtil; import alfio.controller.support.TicketDecorator; +import alfio.manager.TicketReservationManager; import alfio.model.TicketCategory; import lombok.AllArgsConstructor; import lombok.Getter; @@ -31,6 +33,7 @@ import org.springframework.web.servlet.mvc.support.RedirectAttributes; import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; import java.util.HashMap; import java.util.List; import java.util.Locale; @@ -43,6 +46,7 @@ public class ReservationApiV2Controller { private final ReservationController reservationController; + private final TicketReservationManager ticketReservationManager; @@ -70,6 +74,15 @@ public static class TicketsByTicketCategory { return new ResponseEntity<>(model.asMap(), HttpStatus.OK); } + @DeleteMapping("/event/{eventName}/reservation/{reservationId}") + public ResponseEntity cancelPendingReservation(@PathVariable("eventName") String eventName, + @PathVariable("reservationId") String reservationId, + HttpServletRequest request) { + ticketReservationManager.cancelPendingReservation(reservationId, false, null); + SessionUtil.cleanupSession(request); + return new ResponseEntity<>(true, HttpStatus.OK); + } + @PostMapping("/event/{eventName}/reservation/{reservationId}/validate-to-overview") public ResponseEntity> validateToOverview(@PathVariable("eventName") String eventName, @PathVariable("reservationId") String reservationId, @@ -85,4 +98,15 @@ public static class TicketsByTicketCategory { return new ResponseEntity<>(model, HttpStatus.OK); } + @GetMapping("/event/{eventName}/reservation/{reservationId}/overview") + public ResponseEntity> showOverview(@PathVariable("eventName") String eventName, + @PathVariable("reservationId") String reservationId, + Locale locale, + Model model, + HttpSession session) { + var res = reservationController.showOverview(eventName, reservationId, locale, model, session); + model.addAttribute("viewState", res); + return new ResponseEntity<>(model.asMap(), HttpStatus.OK); + } + }