diff options
Autocommit at 07.05.2022 @ 10:22
1 files changed, 8 insertions, 4 deletions
| -rw-r--r-- | src/Services/EventService.cpp | 12 |
diff --git a/src/Services/EventService.cpp b/src/Services/EventService.cpp index cfd0422..59d4b43 100644 --- a/src/Services/EventService.cpp +++ b/src/Services/EventService.cpp @@ -1,5 +1,6 @@ #include "EventService.h" #include "StatusCode.h" +#include <cstring> /* Private */ @@ -16,6 +17,10 @@ unsigned EventService::indexOfEvent(const char* name, const Date& date) { return events.get_count(); } +bool correctReservationPassword(const Reservation& res, const char* password) { + return strcmp(res.get_password(), password) == 0; +} + /* Public */ EventService::EventService(const HallService* hs) { @@ -120,17 +125,16 @@ StatusCode EventService::buyTicket(const char* name, const Date& date, const Tic if (rInd < events[eInd].get_reservations().get_count()) { if (password == nullptr) return E_TicketAlreadyReserved; + if (!correctReservationPassword(events[eInd].get_reservations()[rInd], password)) + return E_WrongReservationPassword; + events[eInd].get_reservations().removeAt(rInd); } events[eInd].get_tickets().insert(ticket); return Success; } -return events[ind].buyTicketFromReservation(Reservation(ticket), password); -} - - const Hall* EventService::queryEventHall(const char* name, const Date& date) { unsigned ind = indexOfEvent(name, date); if (ind == events.get_count()) |
