public IActionResult Create(int mainCategoryId)
        {
            var model = new CreateProductInputViewModel();

            model.SubCategories  = this.categoriesService.GetAllSubCategoriesByParentId <CategoryViewModel>(mainCategoryId);
            model.MainCategoryId = mainCategoryId;
            return(this.View(model));
        }
Esempio n. 2
0
        public IActionResult Create()
        {
            var subcategories = this.subcategoriesService.GetAll();

            var model = new CreateProductInputViewModel
            {
                Subcategories = subcategories,
            };

            return(this.View(model));
        }
Esempio n. 3
0
        public HttpResponse Add(CreateProductInputViewModel model)
        {
            if (!this.IsUserLoggedIn())
            {
                return(this.Redirect("/Users/Login"));
            }

            this.productService.CreateProduct(model.Name, model.Description, model.ImageUrl, model.Category, model.Gender, model.Price);

            return(this.Redirect("/"));
        }
Esempio n. 4
0
        public async Task <IActionResult> Create(CreateProductInputViewModel model)
        {
            if (!this.ModelState.IsValid)
            {
                var subcategories = this.subcategoriesService.GetAll();
                model.Subcategories = subcategories;
                return(this.View(model));
            }

            await this.productsService.CreateAsync <CreateProductInputViewModel>(model, model.UploadedImages, this.fullDirectoryPath, this.webHostEnvironment.WebRootPath);

            this.TempData["Alert"] = "Successfully created product.";

            return(this.RedirectToAction(nameof(this.All)));
        }
        public async Task <IActionResult> Create(CreateProductInputViewModel input)
        {
            if (!this.ModelState.IsValid)
            {
                input.SubCategories = this.categoriesService.GetAllSubCategoriesByParentId <CategoryViewModel>(input.MainCategoryId);
                return(this.View(input));
            }

            var mainPictur = new List <IFormFile>();

            mainPictur.Add(input.MainPicture);

            var mainPicturesUrls = await this.cloudinaryService.UploadAsync(mainPictur);

            var mainPicturesUrl      = mainPicturesUrls.FirstOrDefault();
            var secondaryPictursUrls = await this.cloudinaryService.UploadAsync(input.SecondaryPicturs);

            var id = await this.productsService.CreateAsync(input.Name, input.Color, input.Description, input.Price, input.CategoryId, secondaryPictursUrls, mainPicturesUrl, input.ManufacturerId);

            return(this.RedirectToAction(nameof(this.All)));
        }