public ActionResult Edit(Order order) { var productDb = DbContext.Orders.Find(order.OrderId); if (productDb == null) { ModelState.AddModelError(string.Empty, "Không thể lưu thay đổi, sản phẩm này đã bị xóa"); } if (ModelState.IsValid) { try { TryUpdateModel(productDb); DbContext.Entry(productDb).State = EntityState.Modified; if (DbContext.SaveChanges() > 0) { return Redirect(null); } } catch (Exception ex) { ModelState.AddModelError("", ex.Message); ex.Write(LogPath); } } InitFormData(order); return View(order); }
private void InitFormData(Order order) { }