Exemplo n.º 1
0
        public async Task <ActionResult> AddProduct(ProductViewModel product, HttpPostedFileBase image = null)
        {
            if (ModelState.IsValid)
            {
                if (image != null)
                {
                    image.SaveAs(adminApi.CreateProductFullPath(ref product));
                }

                var productModel = await adminApi.CreateProductAsync(product);

                TempData["message"] = string.Format($"{productModel.Name} was successfully added!");

                return(RedirectToAction("ProductList", "Admin"));
            }
            else
            {
                return(View(product));
            }
        }