/** * @param Request $request * @param $reservationId * @return JsonResponse */ public function patchReservationsAction(Request $request, $reservationId) { if (null === $request->request->get('givenAwayAt')) { return new JsonResponse(null, Response::HTTP_BAD_REQUEST); } try { $this->library->giveAwayBookInReservation(Uuid::fromString($reservationId), new \DateTime($request->request->get('givenAwayAt'))); } catch (BookInReservationAlreadyGivenAway $e) { return new JsonResponse(null, Response::HTTP_BAD_REQUEST); } return new JsonResponse(null, Response::HTTP_OK); }
/** * @When /^I give away book form reservation "([^"]*)" at "([^"]*)"$/ */ public function iGiveAwayBookFormReservationAt($reservationId, $givenAwayAt) { $this->execute(function () use($reservationId, $givenAwayAt) { $this->library->giveAwayBookInReservation(Uuid::fromString($reservationId), new \DateTime($givenAwayAt)); }); }