public function UpdateBlackout()
 {
     $session = ServiceLocator::GetServer()->GetUserSession();
     $id = $this->page->GetUpdateBlackoutId();
     $scope = $this->page->GetSeriesUpdateScope();
     Log::Debug('Updating blackout. BlackoutId=%s, UpdateScope=%s', $id, $scope);
     $resourceIds = $this->page->GetBlackoutResourceIds();
     $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->Update($id, $blackoutDate, $resourceIds, $title, ReservationConflictResolution::Create($conflictAction), $repeatOptions, $scope);
     $this->page->ShowUpdateResult($result->WasSuccessful(), $result->Message(), $result->ConflictingReservations(), $result->ConflictingBlackouts(), $session->Timezone);
 }
 public function testUpdatesBlackout()
 {
     $startDate = '1/1/2011';
     $endDate = '1/2/2011';
     $startTime = '01:30 PM';
     $endTime = '12:15 AM';
     $timezone = $this->fakeUser->Timezone;
     $dr = DateRange::Create($startDate . ' ' . $startTime, $endDate . ' ' . $endTime, $timezone);
     $title = 'out of service';
     $conflictAction = ReservationConflictResolution::Delete;
     $conflictResolution = ReservationConflictResolution::Create($conflictAction);
     $endDateString = '2012-01-01';
     $repeatType = RepeatType::Daily;
     $repeatInterval = 1;
     $repeatDays = array(1, 2);
     $repeatMonthlyType = RepeatMonthlyType::DayOfMonth;
     $blackoutInstanceId = 1111;
     $scope = SeriesUpdateScope::ThisInstance;
     $roFactory = new RepeatOptionsFactory();
     $repeatEndDate = Date::Parse($endDateString, $timezone);
     $repeatOptions = $roFactory->Create($repeatType, $repeatInterval, $repeatEndDate, $repeatDays, $repeatMonthlyType);
     $this->ExpectPageToReturnCommonBlackoutInfo($startDate, $startTime, $endDate, $endTime, $title, $conflictAction);
     $this->ExpectPageToReturnRepeatInfo($repeatType, $repeatInterval, $endDateString, $repeatDays, $repeatMonthlyType);
     $resourceIds = array(123, 456);
     $this->page->expects($this->once())->method('GetBlackoutResourceIds')->will($this->returnValue($resourceIds));
     $this->page->expects($this->once())->method('GetUpdateBlackoutId')->will($this->returnValue($blackoutInstanceId));
     $this->page->expects($this->once())->method('GetSeriesUpdateScope')->will($this->returnValue($scope));
     $result = $this->getMock('IBlackoutValidationResult');
     $this->blackoutsService->expects($this->once())->method('Update')->with($this->equalTo($blackoutInstanceId), $this->equalTo($dr), $this->equalTo($resourceIds), $this->equalTo($title), $this->equalTo($conflictResolution), $this->equalTo($repeatOptions), $this->equalTo($scope))->will($this->returnValue($result));
     $this->presenter->UpdateBlackout();
 }