public async Task <string[]> GetUrlsAsync(string[] objectIds, MediaElementUrlType type, string format, int maxWidthHeight, int percentage) { IEnumerable <ImageElement> imageElements = _repository.GetImagesById(objectIds).ToArray(); var storageIds = imageElements.Select(m => m.StorageId); IEnumerable <Storage> storages = _repository.GetStoragesByIds(storageIds).ToArray(); List <string> urls = new List <string>(); foreach (var objId in objectIds) { ImageElement element = imageElements.FirstOrDefault( m => m.ObjectId.Equals(objId)); if (element == null) { urls.Add(string.Empty); continue; } Storage storage = storages.FirstOrDefault( m => m.StorageId.Equals(element.StorageId)); if (storage == null) { urls.Add(string.Empty); continue; } string url = _storageService.GetUrlByFormatSizeQuality( storage, element.FilePath, element.GetFileName(), type, format, maxWidthHeight, percentage); urls.Add(url); } return(urls.ToArray()); }
public async Task <string> GetUrlAsync(string objectId, MediaElementUrlType type, string styleName) { ImageElement element = _repository.FindImageElementById(objectId); if (element == null) { return(string.Empty); } Storage storage = _storageService.FindStorageById(element.StorageId); if (storage == null) { return(string.Empty); } string url = _storageService.GetUrlByStyle(storage, element.FilePath, element.GetFileName(), type, styleName); return(url); }
public async Task <string> GetUrlAsync(string objectId, MediaElementUrlType type, string format, int maxWidthHeight, int percentage) { ImageElement element = _repository.FindImageElementById(objectId); if (element == null) { return(string.Empty); } Storage storage = _storageService.FindStorageById(element.StorageId); if (storage == null) { return(string.Empty); } string url = _storageService.GetUrlByFormatSizeQuality( storage, element.FilePath, element.GetFileName(), type, format, maxWidthHeight, percentage); return(url); }