public async Task <ActionResult> EditProduct(ProductViewModel product, int?productId, HttpPostedFileBase image = null) { if (product == null || productId == null) { return(View("PageNotFound")); } if (ModelState.IsValid) { if (image != null) { image.SaveAs(adminApi.CreateProductFullPath(ref product)); } var productModel = await adminApi.EditProductAsync((int)productId, product); TempData["message"] = string.Format($"Data in {productModel.ProductId}/{productModel.Name} was successfully changed!"); return(RedirectToAction("ProductList", "Admin")); } else { return(View(product)); } }