Website Summary Files Commits Branches @commit @diff @stats
path: root / src / Services / EventService.cpp
diff options
context:
space:
mode:
Commit6407802f3350e93d39bb0b8c08d06136ca6b448c (patch)
Author
 Syndamia <kamen.d.mladenov@protonmail.com>
2022-05-07 10:22:28 +0300
Committer
 Syndamia <kamen.d.mladenov@protonmail.com>
2022-05-07 10:22:28 +0300
Files53594ead37d937e43c612218c0ed9e382f0d240a /src/Services/EventService.cpp
FMI-OOP-P1_TicketSystem-6407802f3350e93d39bb0b8c08d06136ca6b448c.tar
FMI-OOP-P1_TicketSystem-6407802f3350e93d39bb0b8c08d06136ca6b448c.tar.gz
FMI-OOP-P1_TicketSystem-6407802f3350e93d39bb0b8c08d06136ca6b448c.zip
Parent1f623d9d8ae4e5ea5f776f5c1b6dd51390db96de (diff)
Autocommit at 07.05.2022 @ 10:22
1 files changed, 8 insertions, 4 deletions
-rw-r--r--src/Services/EventService.cpp12
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())