public function inviteSpeaker(SpeakerInvitationInputModel $model) : ServiceResponse
 {
     $lectureId = $model->getLectureId();
     $speakerId = $model->getSpeakerId();
     $conferenceId = $model->getConferenceId();
     $lecture = $this->dbContext->getLecturesRepository()->filterById(" = {$lectureId}")->findOne();
     $speaker = $this->dbContext->getUsersRepository()->filterById(" = {$speakerId}")->findOne();
     if ($lecture->getId() == null) {
         return new ServiceResponse(404, "Lecture not found.");
     }
     if ($speaker->getId() == null) {
         return new ServiceResponse(404, "Speaker not found.");
     }
     $conference = $this->dbContext->getConferencesRepository()->filterById(" = {$conferenceId}")->findOne();
     if ($conference->getId() == null) {
         return new ServiceResponse(404, 'Conference not found.');
     }
     if (HttpContext::getInstance()->getIdentity()->getUserId() != $conference->getOwnerId()) {
         return new ServiceResponse(401, 'Only conference owners can invite speakers.');
     }
     $invitation = $this->dbContext->getSpeakerInvitationsRepository()->filterByLectureId(" = {$lectureId}")->filterBySpeakerId(" = {$speakerId}")->findOne();
     if ($invitation->getId() != null) {
         return new ServiceResponse(409, "Speaker is already invited.");
     }
     $this->dbContext->getSpeakerInvitationsRepository()->filterByLectureId(" = {$lectureId}")->delete();
     $speakerInvitation = new SpeakerInvitation($lectureId, $speakerId, 0);
     $this->dbContext->getSpeakerInvitationsRepository()->add($speakerInvitation);
     $lecture->setSpeaker_Id($speakerId);
     $title = $lecture->getTitle();
     $message = "You received Speaker invitation for the lecture '{$title}'.";
     $notyService = new NotificationsService($this->dbContext);
     $notyService->sendNotification($speakerId, $message);
     $this->dbContext->saveChanges();
     return new ServiceResponse(null, "Invitation sent.");
 }
 public function sendVenueRequest(VenueRequestInputModel $model) : ServiceResponse
 {
     $conferenceId = $model->getConferenceId();
     $venueId = $model->getVenueId();
     $conference = $this->dbContext->getConferencesRepository()->filterById(" = {$conferenceId}")->findOne();
     if ($conference->getId() == null) {
         return new ServiceResponse(404, "Conference not found.");
     }
     $venue = $this->dbContext->getVenuesRepository()->filterById(" = {$venueId}")->findOne();
     if ($venue->getId() == null) {
         return new ServiceResponse(404, "Venue not found.");
     }
     if (HttpContext::getInstance()->getIdentity()->getUserId() != $conference->getOwnerId()) {
         return new ServiceResponse(401, 'Only conference owners are allowed to send venue requests.');
     }
     $testRequest = $this->dbContext->getVenueReservationRequestsRepository()->filterByConferenceId(" = {$conferenceId}")->filterByVenueId(" = {$venueId}")->findOne();
     if ($testRequest->getId() != null) {
         return new ServiceResponse(1, "Request for this venue already exists.");
     }
     $this->dbContext->getVenueReservationRequestsRepository()->filterByConferenceId(" = {$conferenceId}")->delete();
     $conference->setVenue_Id($model->getVenueId());
     $this->dbContext->saveChanges();
     $venueRequest = new VenueReservationRequest($venueId, $conferenceId, 0);
     $this->dbContext->getVenueReservationRequestsRepository()->add($venueRequest);
     $conferenceTitle = $conference->getTitle();
     $venueTitle = $venue->getTitle();
     $message = "You received venue reservation request for venue '{$venueTitle}' by conference '{$conferenceTitle}'.";
     $notyService = new NotificationsService($this->dbContext);
     $notyService->sendNotification($venue->getOwnerId(), $message);
     $this->dbContext->saveChanges();
     return new ServiceResponse(null, "Venue request sent successfully.");
 }