public function BindResource(BookableResource $resource) { $this->Set('resourceName', $resource->GetName()); $this->Set('description', $resource->GetDescription()); $this->Set('notes', $resource->GetNotes()); $this->Set('contactInformation', $resource->GetContact()); $this->Set('locationInformation', $resource->GetLocation()); $this->Set('allowMultiday', $resource->GetAllowMultiday()); $this->Set('minimumDuration', $resource->GetMinLength()); $this->Set('maximumDuration', $resource->GetMaxLength()); $this->Set('maxParticipants', $resource->GetMaxParticipants()); $this->Set('maximumNotice', $resource->GetMaxNotice()); $this->Set('minimumNotice', $resource->GetMinNotice()); $this->Set('requiresApproval', $resource->GetRequiresApproval()); $this->Set('autoAssign', $resource->GetAutoAssign()); if ($resource->HasImage()) { $this->Set('imageUrl', Configuration::Instance()->GetKey(ConfigKeys::IMAGE_UPLOAD_URL) . '/' . $resource->GetImage()); } }
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())); } }