Esempio n. 1
0
        public async Task <IActionResult> Create(ArtProductCreateInputModel input)
        {
            var user = await this.userManager.GetUserAsync(this.User);

            if (!this.ModelState.IsValid)
            {
                return(this.View(input));
            }


            var imageLinks = await this.cloudinaryService.UploadAsync(this.cloudinary, input.ImageLinks);

            List <ImageOfProduct> productsimages = new List <ImageOfProduct>();

            foreach (var image in imageLinks)
            {
                ImageOfProduct imageProduct = new ImageOfProduct();
                imageProduct.Link = image;
                productsimages.Add(imageProduct);
            }

            var artProductId = await this.artProductsService.CreateAsync(
                input.Title, input.Size, input.Price, input.ArtDescription, input.ArtCreatedDate, productsimages,
                input.CategoryId, user.Id, input.Artist.Name, input.Artist.Nationality, input.Artist.Biography,
                input.Artist.BirthDate, input.Artist.DeathDate);

            this.TempData["InfoMessage"] = "ArtProduct has been listed!";

            await this.mailService.SendEmailAsync(user.Email, "hello,there!", "Product Created!");

            return(this.RedirectToAction(nameof(this.ById), new { id = artProductId }));
        }
Esempio n. 2
0
        public IActionResult Create()
        {
            var categories = this.categoriesService.GetAll <CategoryDropDownViewModel>();
            var viewModel  = new ArtProductCreateInputModel
            {
                Categories = categories,
            };

            return(this.View(viewModel));
        }