示例#1
0
 public ActionResult Edit([Bind(Include = "ID,Name,Horsepower,MaxSpeed,Image,Price,ClassID")] Model model)
 {
     if (ModelState.IsValid)
     {
         db.Entry(model).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ClassID = new SelectList(db.Classes, "ID", "Name", model.ClassID);
     return(View(model));
 }
        public ActionResult Edit([Bind(Include = "ID,OrderDate,Price,SelectedClientID,SelectedModelID,AccessoriesIDs")] CreateOrderVM editedOrder)
        {
            Order order = serviceOrder.MapEditedOrderViewModel(db, editedOrder);

            try
            {
                if (ModelState.IsValid && order.OrderDetails != null)
                {
                    //need to check if there is duplicate key in object 'dbo.OrderDetail'
                    db.Entry(order).State = EntityState.Modified;
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            catch (System.Data.SqlClient.SqlException)
            {
            }


            ViewBag.ClientID = new SelectList(db.Clients, "ID", "FirstName", order.ClientID);
            return(View(order));
        }