private function FillRows() { $rows = $this->GetRows(); foreach ($rows as $row) { $this->_Resources[] = BookableResource::Create($row); } }
public function testCanGetAllResourcesForASchedule() { $expected = array(); $scheduleId = 10; $ra = new FakeResourceAccess(); $rows = $ra->GetRows(); $this->db->SetRow(0, $rows); foreach ($rows as $row) { $expected[] = BookableResource::Create($row); } $resourceAccess = new ResourceRepository(); $resources = $resourceAccess->GetScheduleResources($scheduleId); $this->assertEquals(new GetScheduleResourcesCommand($scheduleId), $this->db->_Commands[0]); $this->assertTrue($this->db->GetReader(0)->_FreeCalled); $this->assertEquals(count($rows), count($resources)); $this->assertEquals($expected, $resources); }
private function PopulateResources(ExistingReservationSeries $series) { // get all reservation resources $getResourcesCommand = new GetReservationResourcesCommand($series->SeriesId()); $reader = ServiceLocator::GetDatabase()->Query($getResourcesCommand); while ($row = $reader->GetRow()) { $resource = BookableResource::Create($row); if ($row[ColumnNames::RESOURCE_LEVEL_ID] == ResourceLevel::Primary) { $series->WithPrimaryResource($resource); } else { $series->WithResource($resource); } } $reader->Free(); }
/** * @param $command SqlCommand * @return BookableResource */ private function LoadResource($command) { $reader = ServiceLocator::GetDatabase()->Query($command); $resource = BookableResource::Null(); if ($row = $reader->GetRow()) { $resource = BookableResource::Create($row); $getAttributes = new GetAttributeValuesCommand($resource->GetId(), CustomAttributeCategory::RESOURCE); $attributeReader = ServiceLocator::GetDatabase()->Query($getAttributes); while ($attributeRow = $attributeReader->GetRow()) { $resource->WithAttribute(new AttributeValue($attributeRow[ColumnNames::ATTRIBUTE_ID], $attributeRow[ColumnNames::ATTRIBUTE_VALUE])); } $attributeReader->Free(); } $reader->Free(); return $resource; }