コード例 #1
0
 /**
  * @param VenueInputModel $model
  * @return ServiceResponse
  * @throws \Exception
  */
 public function addVenue(VenueInputModel $model) : ServiceResponse
 {
     $venue = new Venue($model->getTitle(), $model->getDescription(), $model->getAddress(), HttpContext::getInstance()->getIdentity()->getUserId());
     $this->dbContext->getVenuesRepository()->add($venue);
     $this->dbContext->saveChanges();
     $title = $model->getTitle();
     $owner = HttpContext::getInstance()->getIdentity()->getUsername();
     $message = "New conference titled '{$title}' was added by user {$owner}.";
     $notyService = new NotificationsService($this->dbContext);
     $notyService->postToAll($message);
     return new ServiceResponse(null, 'Venue added successfully.');
 }
コード例 #2
0
 /**
  * @param ConferenceInputModel $model
  * @return ServiceResponse
  * @throws \Exception
  */
 public function addConference(ConferenceInputModel $model) : ServiceResponse
 {
     if (strtotime($model->getEndDate()) <= strtotime($model->getStartDate())) {
         return new ServiceResponse(1, 'End date must be after Start date.');
     }
     $conference = new Conference($model->getTitle(), $model->getStartDate(), $model->getEndDate(), HttpContext::getInstance()->getIdentity()->getUserId(), null);
     $this->dbContext->getConferencesRepository()->add($conference);
     $this->dbContext->saveChanges();
     $title = $model->getTitle();
     $organiser = HttpContext::getInstance()->getIdentity()->getUsername();
     $message = "New conference titled '{$title}' was added by user {$organiser}.";
     $notyService = new NotificationsService($this->dbContext);
     $notyService->postToAll($message);
     return new ServiceResponse(null, 'Conference added successfully.');
 }