Beispiel #1
0
        public ActionResult EditMenuPost(int?id)
        {
            var menuUpdate = db.Menus.Find(id);

            if (TryUpdateModel(menuUpdate, "", new string[] { "Name", "Price", "OfferPercent", "Selled", "Image" }))
            {
                try
                {
                    db.Entry(menuUpdate).State = EntityState.Modified;
                    db.SaveChanges();
                }
                catch (Exception)
                {
                    ModelState.AddModelError("", "Error Save Data");
                }
            }
            return(RedirectToAction("ListMenu"));
        }
        public ActionResult UpdateOrder(OrderInfo form, string id)
        {
            var order = db.Orders.First(m => m.ID == id);

            if (TryUpdateModel(order, "", new string[] { "ID", "Date", "DisplayName", "IDCustomer", "IDShip", "Status" }))
            {
                try
                {
                    db.Entry(order).State = EntityState.Modified;
                    db.SaveChanges();
                }
                catch (Exception)
                {
                    ModelState.AddModelError("", "Error Save Data");
                }
            }
            return(RedirectToAction("ListOrder"));
        }