public ActionResult Edit([Bind(Include = "ID,ProductName,ProductPrice,ProductSize,ProductColor,Quantity,ProductImg,Meta,Hide,Order,Datebegin,ProductDescription,MenuCateID")] Product product, HttpPostedFileBase img) { var filename = ""; var path = ""; if (ModelState.IsValid) { if (img != null) { filename = img.FileName; path = Path.Combine(Server.MapPath("~/Images/Products/"), filename); img.SaveAs(path); product.ProductImg = filename; } else { product.ProductImg = ""; } db.Entry(product).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.MenuCateID = new SelectList(db.MenuCategory, "ID", "MenuCateName", product.MenuCateID); return(View(product)); }
public ActionResult Edit([Bind(Include = "ID,NewName,NewImg,Desciption,Link,Detail,Meta,Hide,Order,Datebegin")] FashionShop.Models.EF.News news, HttpPostedFileBase img) { var filename = ""; var path = ""; FashionShop.Models.EF.News temp = new FashionShop.Models.DAO.News().getById(news.ID); if (ModelState.IsValid) { if (img != null) { filename = img.FileName; path = Path.Combine(Server.MapPath("~/Images/Products/"), filename); img.SaveAs(path); temp.NewImg = filename; } temp.NewName = news.NewName; temp.Desciption = news.Desciption; temp.Detail = news.Detail; temp.Meta = news.Meta; temp.Hide = news.Hide; temp.Order = news.Order; temp.Datebegin = news.Datebegin; db.Entry(temp).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(news)); }
public ActionResult Edit([Bind(Include = "ID,MenuName,Link,Meta,Hide,Order,Datebegin")] Menu menu) { if (ModelState.IsValid) { db.Entry(menu).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(menu)); }
public ActionResult Edit([Bind(Include = "ID,ClientName,PhoneNumber,Address,OrderDate,DeliveryDate,Paid,Status,Meta,Hide,Order1,Datebegin,ClientID")] Order order) { if (ModelState.IsValid) { db.Entry(order).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ClientID = new SelectList(db.Client, "ID", "UserName", order.ClientID); return(View(order)); }
public ActionResult Edit([Bind(Include = "ID,SlideName,SlideImg,Description,Link,Meta,Hide,Order,Datebegin")] Slide slide, HttpPostedFileBase img) { var fileName = ""; var path = ""; if (ModelState.IsValid) { if (img != null) { fileName = img.FileName; path = Path.Combine(Server.MapPath("~/Images/Slides/"), fileName); img.SaveAs(path); slide.SlideImg = fileName; } db.Entry(slide).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(slide)); }