public IActionResult Create(CreateProductVewModel model)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.Redirect("/Products/Create"));
            }

            this.productsService.CreateProduct(model.Name, model.Price);

            return(this.Redirect("/Products/All"));
        }
        public ActionResult Create(CreateProductVewModel model, HttpPostedFileBase imageFile)
        {
            string fileName      = Guid.NewGuid().ToString() + ".jpg";
            string fullPathImage = Server.MapPath(ImageConfig.ProductImagePath) + "\\" + fileName;

            using (Bitmap bmp = new Bitmap(imageFile.InputStream))
            {
                var readyImage = Image_Helper.CreateImage(bmp, 450, 450);
                if (readyImage != null)
                {
                    readyImage.Save(fullPathImage, ImageFormat.Jpeg);
                    Product newProduct = new Product
                    {
                        ImageName = fileName,
                        Name      = model.Name,
                        Price     = model.Price
                    };
                    _context.products.Add(newProduct);
                    _context.SaveChanges();
                }
            }
            return(RedirectToAction("Index", "Home"));
        }