Esempio n. 1
0
 /**
  * @param IRestServer $server
  * @param BookableResource $resource
  * @param IEntityAttributeList $attributes
  */
 public function __construct(IRestServer $server, $resource, $attributes)
 {
     $resourceId = $resource->GetId();
     $this->resourceId = $resourceId;
     $this->name = $resource->GetName();
     $this->location = $resource->GetLocation();
     $this->contact = $resource->GetContact();
     $this->notes = $resource->GetNotes();
     $this->maxLength = $resource->GetMaxLength()->__toString();
     $this->minLength = $resource->GetMinLength()->__toString();
     $this->maxNotice = $resource->GetMaxNotice()->__toString();
     $this->minNotice = $resource->GetMinNotice()->__toString();
     $this->requiresApproval = $resource->GetRequiresApproval();
     $this->allowMultiday = $resource->GetAllowMultiday();
     $this->maxParticipants = $resource->GetMaxParticipants();
     $this->description = $resource->GetDescription();
     $this->scheduleId = $resource->GetScheduleId();
     $this->statusId = $resource->GetStatusId();
     $this->statusReasonId = $resource->GetStatusReasonId();
     $this->bufferTime = $resource->GetBufferTime()->__toString();
     $attributeValues = $attributes->GetAttributes($resourceId);
     $i = 0;
     foreach ($attributeValues as $av) {
         $this->customAttributes[] = new CustomAttributeResponse($server, $av->Id(), $av->Label(), $av->Value());
         $i++;
     }
     if ($resource->GetIsCalendarSubscriptionAllowed()) {
         $url = new CalendarSubscriptionUrl(null, null, $resource->GetPublicId());
         $this->icsUrl = $url->__toString();
     }
     $this->AddService($server, WebServices::GetResource, array(WebServiceParams::ResourceId => $resourceId));
 }
Esempio n. 2
0
 public function Update(BookableResource $resource)
 {
     $db = ServiceLocator::GetDatabase();
     $updateResourceCommand = new UpdateResourceCommand($resource->GetResourceId(), $resource->GetName(), $resource->GetLocation(), $resource->GetContact(), $resource->GetNotes(), $resource->GetMinLength(), $resource->GetMaxLength(), $resource->GetAutoAssign(), $resource->GetRequiresApproval(), $resource->GetAllowMultiday(), $resource->GetMaxParticipants(), $resource->GetMinNotice(), $resource->GetMaxNotice(), $resource->GetDescription(), $resource->GetImage(), $resource->GetScheduleId(), $resource->GetAdminGroupId(), $resource->GetIsCalendarSubscriptionAllowed(), $resource->GetPublicId(), $resource->GetSortOrder(), $resource->GetResourceTypeId(), $resource->GetStatusId(), $resource->GetStatusReasonId(), $resource->GetBufferTime());
     $db->Execute($updateResourceCommand);
     foreach ($resource->GetRemovedAttributes() as $removed) {
         $db->Execute(new RemoveAttributeValueCommand($removed->AttributeId, $resource->GetId()));
     }
     foreach ($resource->GetAddedAttributes() as $added) {
         $db->Execute(new AddAttributeValueCommand($added->AttributeId, $added->Value, $resource->GetId(), CustomAttributeCategory::RESOURCE));
     }
     if ($resource->WasAutoAssignToggledOn()) {
         $db->Execute(new AutoAssignResourcePermissionsCommand($resource->GetId()));
     }
 }
 public function testCanUpdateResource()
 {
     $id = 8383;
     $name = "name";
     $location = "location";
     $contact = "contact";
     $notes = "notes";
     $minLength = 720;
     $maxLength = 727272;
     $autoAssign = 1;
     $requiresApproval = 0;
     $allowMultiday = 1;
     $maxParticipants = 100;
     $minNotice = 11111;
     $maxNotice = 22222;
     $description = "description";
     $scheduleId = 19819;
     $imageName = 'something.png';
     $adminGroupId = 232;
     $allowSubscription = true;
     $sortOrder = 3;
     $resourceTypeId = 111;
     $reasonId = 19;
     $bufferTime = 88881;
     $resource = new BookableResource($id, $name, $location, $contact, $notes, $minLength, $maxLength, $autoAssign, $requiresApproval, $allowMultiday, $maxParticipants, $minNotice, $maxNotice, $description, $scheduleId);
     $resource->SetImage($imageName);
     $resource->ChangeStatus(ResourceStatus::AVAILABLE, $reasonId);
     $resource->SetAdminGroupId($adminGroupId);
     $resource->EnableSubscription();
     $resource->SetSortOrder($sortOrder);
     $resource->SetResourceTypeId($resourceTypeId);
     $resource->SetBufferTime($bufferTime);
     $publicId = $resource->GetPublicId();
     $this->repository->Update($resource);
     $expectedUpdateResourceCommand = new UpdateResourceCommand($id, $name, $location, $contact, $notes, new TimeInterval($minLength), new TimeInterval($maxLength), $autoAssign, $requiresApproval, $allowMultiday, $maxParticipants, new TimeInterval($minNotice), new TimeInterval($maxNotice), $description, $imageName, $scheduleId, $adminGroupId, $allowSubscription, $publicId, $sortOrder, $resourceTypeId, ResourceStatus::AVAILABLE, $reasonId, new TimeInterval($bufferTime));
     $actualUpdateResourceCommand = $this->db->_Commands[0];
     $this->assertEquals($expectedUpdateResourceCommand, $actualUpdateResourceCommand);
 }