public function PageLoad(UserSession $user)
 {
     $now = Date::Now();
     $resources = $this->resourceService->GetAllResources(false, $user);
     $reservations = $this->GetReservations($this->reservationViewRepository->GetReservationList($now, $now));
     $next = $this->reservationViewRepository->GetNextReservations($now);
     $available = array();
     $unavailable = array();
     $allday = array();
     foreach ($resources as $resource) {
         $reservation = $this->GetOngoingReservation($resource, $reservations);
         if ($reservation != null) {
             if (!$reservation->EndDate->DateEquals(Date::Now())) {
                 $allday[] = new UnavailableDashboardItem($resource, $reservation);
             } else {
                 $unavailable[] = new UnavailableDashboardItem($resource, $reservation);
             }
         } else {
             if (array_key_exists($resource->GetId(), $next)) {
                 $available[] = new AvailableDashboardItem($resource, $next[$resource->GetId()]);
             } else {
                 $available[] = new AvailableDashboardItem($resource);
             }
         }
     }
     $this->control->SetAvailable($available);
     $this->control->SetUnavailable($unavailable);
     $this->control->SetUnavailableAllDay($allday);
 }
 public function PageLoad(UserSession $user)
 {
     $now = Date::Now();
     $resources = $this->resourceService->GetAllResources(false, $user);
     $reservations = $this->GetReservations($this->reservationViewRepository->GetReservationList($now, $now->AddDays(30)));
     $available = array();
     $unavailable = array();
     $allday = array();
     foreach ($resources as $resource) {
         $reservation = $this->GetOngoingReservation($resource, $reservations);
         if ($reservation != null) {
             $lastReservationBeforeOpening = $this->GetLastReservationBeforeAnOpening($resource, $reservations);
             if ($lastReservationBeforeOpening == null) {
                 $lastReservationBeforeOpening = $reservation;
             }
             if (!$reservation->EndDate->DateEquals($now)) {
                 $allday[] = new UnavailableDashboardItem($resource, $lastReservationBeforeOpening);
             } else {
                 $unavailable[] = new UnavailableDashboardItem($resource, $lastReservationBeforeOpening);
             }
         } else {
             $resourceId = $resource->GetId();
             if (array_key_exists($resourceId, $reservations)) {
                 $available[] = new AvailableDashboardItem($resource, $reservations[$resourceId][0]);
             } else {
                 $available[] = new AvailableDashboardItem($resource);
             }
         }
     }
     $this->control->SetAvailable($available);
     $this->control->SetUnavailable($unavailable);
     $this->control->SetUnavailableAllDay($allday);
 }