private async Task <RequestedImage> DownloadImageAsync(string url, string filePath) { try { return(await FileHandler.Download(url, filePath) ? RequestedImageHandler.GetRequestedImageForDownloadSuccess(url, filePath): RequestedImageHandler.GetRequestedImageForDownloadFailure(url, filePath)); } catch (BaseApplicationException exception) { return(RequestedImageHandler.GetRequestedImage(url, filePath, exception)); } }
public async Task <List <RequestedImage> > DownloadImagesAsync(List <string> urls) { var requestedImages = new List <RequestedImage>() { }; foreach (var url in urls) { RequestedImage requestedImage = null; if (String.IsNullOrEmpty(url)) { requestedImage = RequestedImageHandler.GetRequestedImageForNullOrEmptyURL(url); } else { var filePath = Path.Combine(BasePath.BaseDirectory, Location.Images, Guid.NewGuid().ToString() + ".jpg"); requestedImage = await DownloadImageAsync(url, filePath); } requestedImages.Add(requestedImage); } return(requestedImages); }