Example #1
0
 /**
  * @name GetSlots
  * @description Loads slots for a specific schedule
  * Optional query string parameters:  resourceId, startDateTime, endDateTime.
  * If no dates are provided the default schedule dates will be returned.
  * If dates do not include the timezone offset, the timezone of the authenticated user will be assumed.
  * @response ScheduleSlotsResponse
  * @param $scheduleId
  * @return void
  */
 public function GetSlots($scheduleId)
 {
     $startDate = $this->GetDate(WebServiceQueryStringKeys::START_DATE_TIME);
     $endDate = $this->GetDate(WebServiceQueryStringKeys::END_DATE_TIME);
     $resourceId = $this->server->GetQueryString(WebServiceQueryStringKeys::RESOURCE_ID);
     $scheduleWebServiceView = new ScheduleWebServiceView($scheduleId, $startDate);
     $permissionServiceFactory = new PermissionServiceFactory();
     $scheduleRepository = new ScheduleRepository();
     $userRepository = new UserRepository();
     $resourceService = new ResourceService(new ResourceRepository(), $permissionServiceFactory->GetPermissionService(), new AttributeService(new AttributeRepository()), $userRepository);
     $builder = new ScheduleWebServicePageBuilder($startDate, $endDate, $resourceId);
     $reservationService = new ReservationService(new ReservationViewRepository(), new ReservationListingFactory());
     $dailyLayoutFactory = new DailyLayoutFactory();
     $scheduleService = new ScheduleService($scheduleRepository, $resourceService);
     $presenter = new SchedulePresenter($scheduleWebServiceView, $scheduleService, $resourceService, $builder, $reservationService, $dailyLayoutFactory);
     $presenter->PageLoad($this->server->GetSession());
     $layout = $scheduleWebServiceView->GetDailyLayout();
     $isError = $scheduleWebServiceView->IsPermissionError();
     $dates = $scheduleWebServiceView->GetDates();
     $resources = $scheduleWebServiceView->GetResources();
     if ($isError) {
         $this->server->WriteResponse(RestResponse::Unauthorized(), RestResponse::UNAUTHORIZED_CODE);
     } else {
         $response = new ScheduleSlotsResponse($this->server, $scheduleId, $layout, $dates, $resources, $this->privacyFilter);
         $this->server->WriteResponse($response);
     }
 }
 public function testCanGetLayoutForScheduleOnDate()
 {
     $user = $this->fakeUser;
     $page = $this->getMock('ISchedulePage');
     $scheduleService = $this->getMock('IScheduleService');
     $resourceService = $this->getMock('IResourceService');
     $pageBuilder = $this->getMock('ISchedulePageBuilder');
     $reservationService = $this->getMock('IReservationService');
     $dailyLayoutFactory = $this->getMock('IDailyLayoutFactory');
     $layout = $this->getMock('IScheduleLayout');
     $dateString = '2013-01-07';
     $date = Date::Parse($dateString, $user->Timezone);
     $periods = array();
     $scheduleId = 1928;
     $expectedLayoutResponse = new ScheduleLayoutSerializable($periods);
     $page->expects($this->once())->method('GetScheduleId')->will($this->returnValue($scheduleId));
     $page->expects($this->once())->method('GetLayoutDate')->will($this->returnValue($dateString));
     $scheduleService->expects($this->once())->method('GetLayout')->with($this->equalTo($scheduleId), $this->equalTo(new ScheduleLayoutFactory($user->Timezone)))->will($this->returnValue($layout));
     $layout->expects($this->once())->method('GetLayout')->with($this->equalTo($date))->will($this->returnValue($periods));
     $page->expects($this->once())->method('SetLayoutResponse')->with($this->equalTo($expectedLayoutResponse));
     $presenter = new SchedulePresenter($page, $scheduleService, $resourceService, $pageBuilder, $reservationService, $dailyLayoutFactory);
     $presenter->GetLayout($user);
 }
Example #3
0
 public function ProcessDataRequest($dataRequest)
 {
     $this->_presenter->GetLayout(ServiceLocator::GetServer()->GetUserSession());
 }