public async Task <ClientImageModel> DownloadLatest(ImageQuality quality) { FileModel file = await service.FindLatestImageAsync(); Stream content = file.Content.AsStreamForRead(); switch (quality) { case ImageQuality.Full: break; case ImageQuality.Medium: int width = 600; content = await ResizeImage(content, width, 0); break; case ImageQuality.Thumbnail: width = 200; content = await ResizeImage(content, width, 0); break; default: throw new NotSupportedException(quality.ToString()); } BitmapImage image = new BitmapImage(); await image.SetSourceAsync(content.AsRandomAccessStream()); return(new ClientImageModel() { Image = image, Stream = content, Date = file.CreatedAt }); }