Esempio n. 1
0
        public async Task CreateGallery()
        {
            var gallery = new GalleryNewDTO()
            {
                Title  = Title,
                Photos = Files.Files
                         .Select(f => new PhotoNewDTO()
                {
                    FileName = f.FileName,
                    Stream   = uploadedFileStorage.GetFile(f.FileId)
                })
                         .ToList()
            };

            try
            {
                await galleryService.CreateGallery(gallery);

                Context.RedirectToRoute("Default");
            }
            finally
            {
                foreach (var photo in gallery.Photos)
                {
                    photo.Stream?.Dispose();
                }
            }
        }
Esempio n. 2
0
        public async Task <IActionResult> Create(GalleryCreateVM viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(viewModel));
            }

            await service.CreateGallery(viewModel);

            return(RedirectToAction(nameof(Index)));
        }