private void SyncProperty(ApiProperty property) { IProperty propertyEntity = _apiPropertyDataProvider.Read(property.PropertyId); ApiPropertyEntity apiPropertyEntity = new ApiPropertyEntity(property, propertyEntity); _apiPropertyDataProvider.Save(property, apiPropertyEntity); SyncResources(property, propertyEntity, apiPropertyEntity); }
private void SyncResources(ApiProperty property, IProperty propertyEntity, ApiPropertyEntity apiPropertyEntity) { IEnumerable <Resource> resources = property.Images .Union(property.Floorplans) .Union(property.EpcGraphs) .Where(x => ShouldUpdate(x, propertyEntity)); ResourceCollection resourceCollection = new ResourceCollection(resources); DownloadResources(resourceCollection); SaveResources(resourceCollection, apiPropertyEntity); }
private void SaveResources(ResourceCollection resources, ApiPropertyEntity apiPropertyEntity) { foreach (Resource resource in resources) { if (resource.Status == DownloadStatus.Success) { try { _apiPropertyDataProvider.SaveFile(EntityType.Property, apiPropertyEntity.PropertyId.Value, new ApiFileEntity(resources, resource)); _log.Info($"Saving resource {resource.FileName} for property {apiPropertyEntity.Title}."); } catch (Exception e) { _log.Exception(e); _review.Exceptions.Add(e); } } else { _log.Warning($"Resource {resource.Uri} returned a status of {resource.Status} for {apiPropertyEntity.Title}, resource will not be saved."); } } }