public ActionResult Edit([Bind(Include = "CategoryID,NameCategory")] Category category) { if (ModelState.IsValid) { db.Entry(category).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(category)); }
public ActionResult Edit(Order order) { if (ModelState.IsValid) { db.Entry(order).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(order)); var statusItems = new[] { new { Id = "0", Name = "Đang chờ xác nhận" }, new { Id = "1", Name = "Đã nhận" }, new { Id = "2", Name = "Đang xử lý và đóng gói " }, new { Id = "3", Name = "Đang trên đường giao hàng" }, new { Id = "4", Name = "Đã nhận hàng" } }; }
public ActionResult Edit(ContactDetail ct) { if (ModelState.IsValid) { try { db.Entry(ct).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } catch (Exception) { } } return(View(ct)); }
public ActionResult Edit(Product product) { checkPrice(product); checkProductCodeEdit(product); checkQuantityAndStatus(product); if (ModelState.IsValid) { using (var scope = new TransactionScope()) { //save edit of product product.UpdateDate = DateTime.Now; db.Entry(product).State = EntityState.Modified; db.SaveChanges(); //add file to app_data var path = Server.MapPath("~/Content/Images"); path = System.IO.Path.Combine(path, product.ID.ToString()); if (Request.Files["Image"].ContentLength != 0) { Request.Files["Image"].SaveAs(path); } product.ImageURL = path; //gán đường dẫn vào ImageURL //All done successfully db.SaveChanges(); // save lại đường dẫn scope.Complete(); return(RedirectToAction("Index")); } } ViewBag.CategoryID = new SelectList(db.Categories, "CategoryID", "NameCategory", product.CategoryID); var statusItems = new[] { new { Id = "DEACTIVE", Name = "Hết hàng" }, new { Id = "ACTIVE", Name = "Còn hàng" }, }; ViewBag.Status = new SelectList(statusItems, "Id", "Name"); return(View(product)); }