From dda51cdb8b8495c5d41fc190c6a94d3ff8b1ed52 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sat, 7 May 2022 15:53:32 +0300 Subject: Autocommit at 07.05.2022 @ 15:53 --- src/Services/EventService.cpp | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'src/Services/EventService.cpp') diff --git a/src/Services/EventService.cpp b/src/Services/EventService.cpp index 3c3b668..dd8938f 100644 --- a/src/Services/EventService.cpp +++ b/src/Services/EventService.cpp @@ -158,23 +158,31 @@ String EventService::createSeatingString(const char* name, const Date& date, uns return out; } -bool cond_event_all(const Event& e1, const Event& e2) { +template +bool cond_event_all(const Event& e1, T scrap) { return true; } -bool cond_event_name(const Event& e1, const Event& e2) { - return e1.get_name().compare(e2.get_name()) == 0; +bool cond_event_name(const Event& e, const char* name) { + return e.get_name().compare(name) == 0; } -bool cond_event_date(const Event& e1, const Event& e2) { - return e1.get_date().compare(e2.get_date()) == 0; +bool cond_event_date(const Event& e, const Date& date) { + return e.get_date().compare(date) == 0; } StatusCode EventService::reportReservations(const char* name, const Date& date) { List result; - bool (*cond_name)(const Event&, const Event&) = cond_event_name; - bool (*cond_date)(const Event&, const Event&) = cond_event_date; + bool (*cond_name)(const Event&, const char*) = cond_event_name; + bool (*cond_date)(const Event&, const Date&) = cond_event_date; if (strcmp(name, "ALL") == 0) cond_name = cond_event_all; if (date.compare(Date(0, 0, 0)) == 0) cond_date = cond_event_all; + + for (unsigned i = 0; i < events.get_count(); i++) { + for (unsigned j = 0; i < events[i].get_reservations().get_count(); j++) { + if (cond_name(events[i].get_reservations()[j], name) && cond_date(events[i].get_reservations()[j], date)) + result.add(events[i].get_reservations()[j]); + } + } } -- cgit v1.3.1-23-gd82d