public function addLecture(LectureInputModel $model) : ServiceResponse { $lecture = new Lecture($model->getTitle(), $model->getDescription(), $model->getStartDate(), $model->getEndDate(), $model->getConferenceId(), null, null); $this->dbContext->getLecturesRepository()->add($lecture); $this->dbContext->saveChanges(); return new ServiceResponse(null, "Lecture created successfully."); }
/** * @Method('GET', 'POST') * @Route('lectures/add/{integer $conferenceId}') * @param LectureInputModel $model * @param $conferenceId * @return View */ public function add(LectureInputModel $model, integer $conferenceId) { if (!$model->isValid()) { return new View('lectures', 'add', $model); } $service = new LecturesService($this->dbContext); if (HttpContext::getInstance()->isPost()) { $result = $service->addLecture($model); if (!$result->hasError()) { $this->addInfoMessage($result->getMessage()); $this->redirectToUrl('/conferences/details/' . $conferenceId); } else { $this->addErrorMessage($result->getMessage()); $this->redirectToUrl('/conferences/details/' . $conferenceId); } } else { $model = new LectureInputModel(); $model->setConferenceId($conferenceId); return new View('lectures', 'add', $model); } $result = $service->addLecture($model); $this->processResponse($result); $this->redirect('conferences', 'own'); }