Exemplo n.º 1
0
 public function AddBlackout()
 {
     $session = ServiceLocator::GetServer()->GetUserSession();
     $resourceIds = array();
     if ($this->page->GetApplyBlackoutToAllResources()) {
         $scheduleId = $this->page->GetBlackoutScheduleId();
         $resources = $this->resourceRepository->GetScheduleResources($scheduleId);
         foreach ($resources as $resource) {
             $resourceIds[] = $resource->GetId();
         }
     } else {
         $resourceIds[] = $this->page->GetBlackoutResourceId();
     }
     $startDate = $this->page->GetBlackoutStartDate();
     $startTime = $this->page->GetBlackoutStartTime();
     $endDate = $this->page->GetBlackoutEndDate();
     $endTime = $this->page->GetBlackoutEndTime();
     $blackoutDate = DateRange::Create($startDate . ' ' . $startTime, $endDate . ' ' . $endTime, $session->Timezone);
     $title = $this->page->GetBlackoutTitle();
     $conflictAction = $this->page->GetBlackoutConflictAction();
     $repeatOptionsFactory = new RepeatOptionsFactory();
     $repeatOptions = $repeatOptionsFactory->CreateFromComposite($this->page, $session->Timezone);
     $result = $this->manageBlackoutsService->Add($blackoutDate, $resourceIds, $title, ReservationConflictResolution::Create($conflictAction), $repeatOptions);
     $this->page->ShowAddResult($result->WasSuccessful(), $result->Message(), $result->ConflictingReservations(), $result->ConflictingBlackouts(), $session->Timezone);
 }