public ActionResult CreateProduct(Product product) { if (Request.Files.Count > 0) { string dosyaAdi = Guid.NewGuid().ToString().Replace("-", ""); string uzanti = System.IO.Path.GetExtension(Request.Files[0].FileName); string tamYol = "~/Content/Images/ProductPictures/" + dosyaAdi + uzanti; Request.Files[0].SaveAs(Server.MapPath(tamYol)); product.PicturePath = dosyaAdi + uzanti; } List <Product> productList = productAccess.GetProudcts(); if (!ModelState.IsValid) { ViewBag.Message = "Girdiğiniz bilgileri kontrol ediniz."; return(View()); } PopulateCategoryList(); productList = productAccess.GetProudcts(); var ısCreate = productAccess.CreateProduct(product); ViewBag.Message = "Kayıt Başarılı!"; return(RedirectToAction("GetProduct", productList)); }
public ActionResult CreateProduct(Product product) { if (ModelState.IsValid) { string status = ProductAccess.CreateProduct(product); ViewBag.CreationStatus = status; } else { RedirectToAction("ProductForm"); } return(RedirectToAction("Status", "Product")); }