public async Task CreateGallery(GalleryNewDTO galleryData) { var gallery = new Gallery() { Id = Guid.NewGuid().ToString(), Title = galleryData.Title, CreatedDate = DateTime.UtcNow, PhotosCount = galleryData.Photos.Count }; foreach (var photoData in galleryData.Photos) { var photo = new Photo() { Id = Guid.NewGuid().ToString(), GalleryId = gallery.Id, FileName = photoData.FileName }; await photosContainer.CreateItemAsync(photo); await photoStorageService.StorePhoto(photo.Id, photoData.Stream); await newPhotoNotificiationService.NotifyNewPhotoUploaded(new ProcessPhotoMessage() { Id = photo.Id, GalleryId = gallery.Id }); } await galleriesContainer.CreateItemAsync(gallery); }
private async Task SaveImageAsync(IPhotoStorageService photoStorageService, Photo unprocessedPhoto, Image <Rgba32> image) { using (var ms = new MemoryStream()) { image.Save(ms, new JpegEncoder() { Quality = 95 }); ms.Position = 0; await photoStorageService.StorePhoto(unprocessedPhoto.Id, ms); } }