public function index() : View
 {
     $service = new ConferenceService($this->dbContext);
     $allConferences = $service->getAll();
     $allConferences = array_slice($allConferences, 0, 6);
     return new View('Home', 'Index', $allConferences);
 }
 /**
  * @Authorize
  * @Route("Lecture/{int id}/Invite/Speaker")
  */
 public function inviteSpeaker() : View
 {
     $lectureId = intval(func_get_args()[0]);
     $lecture = $this->dbContext->getLecturesRepository()->filterById(" = '{$lectureId}'")->findOne();
     $conferenceId = intval($lecture->getConferenceId());
     $loggedUserId = $this->identity->getUserId();
     $conferenceService = new ConferenceService($this->dbContext);
     $conference = $conferenceService->getOne($conferenceId);
     $conferenceAdmins = $this->dbContext->getConferenceadminsRepository()->filterByConferenceId(" = '{$conferenceId}'")->findAll()->getConferenceadmins();
     if (!$this->identity->isInRole("Admin")) {
         if ($loggedUserId !== intval($conference->getOwnerId())) {
             $unauthorized = true;
             foreach ($conferenceAdmins as $admin) {
                 if (intval($admin->getUserId()) === $loggedUserId) {
                     $unauthorized = false;
                     $viewBag['isAdmin'] = true;
                     break;
                 }
             }
             if ($unauthorized) {
                 $this->addErrorMessage("You are not the owner of this conference!");
                 $this->redirect('Me', 'Conferences');
             }
         }
     }
     $model = new AddSpeakerBindingModel($lectureId);
     if ($this->context->isPost()) {
         $this->validateToken();
         $username = $model->getUsername();
         $user = $this->dbContext->getUsersRepository()->filterByUsername(" = '{$username}'")->findOne();
         if (!$user->getId()) {
             $this->addErrorMessage('No such user!');
             $this->redirectToUrl("/Lecture/{$lectureId}/Invite/Speaker");
         }
         $userId = intval($user->getId());
         $speakerCheck = $this->dbContext->getLecturesspeakersRepository()->filterBySpeakerId(" = '{$userId}'")->filterByLectureId(" = '{$lectureId}'")->findOne();
         if ($speakerCheck->getId()) {
             $this->addErrorMessage('This user is already a speaker in this lecture!');
             $this->redirectToUrl("/Lecture/{$lectureId}/Invite/Speaker");
         }
         $speakerInvite = new Speakerinvite($userId, $lectureId);
         $this->dbContext->getSpeakerinvitesRepository()->add($speakerInvite);
         $this->dbContext->saveChanges();
         $this->addInfoMessage('User invited to lecture speakers!');
         $this->redirectToUrl('/Lecture/' . $lectureId . '/Manage');
     }
     return new View('lectures', 'inviteSpeaker', $model);
 }
 private function getBestSequence(int $id)
 {
     $service = new ConferenceService($this->dbContext);
     $bestSequence = $service->getBestSchedule($id);
     return $bestSequence;
 }