Esempio n. 1
0
        public IActionResult Add(string id)
        {
            var galleries = this.galleryService.GetAll <GalleryIdNameViewModel>();

            var viewModel = new ImageAddInputModel
            {
                GalleryId = id,
                Galleries = galleries,
            };

            return(this.View(viewModel));
        }
Esempio n. 2
0
        public async Task <IActionResult> Add(ImageAddInputModel input)
        {
            if (!this.ModelState.IsValid)
            {
                var galleries = this.galleryService.GetAll <GalleryIdNameViewModel>();
                input.Galleries = galleries;

                return(this.View(input));
            }

            string rootPath = this.hostEnvironment.WebRootPath;
            var    imageArr = await ImageService.ConvertIFormFileToByteArray(input.Image);

            var imageName = await CloudinaryService.UploadAsync(this.cloudinary, imageArr, "Images", rootPath, false);

            await this.imageService.AddAsync(input.Name, imageName, input.GalleryId, input.Description);

            return(this.RedirectToAction("Id", "Galleries", new { area = string.Empty, Id = input.GalleryId }));
        }