public ActionResult Del(int id) { MyOrder target = new MyOrder() { Id=id }; DbEntityEntry entry=db.Entry(target); entry.State = System.Data.Entity.EntityState.Deleted; db.SaveChanges(); return Json("OK"); }
public ActionResult Update(MyOrder model) { if (ModelState.IsValid == false) { return Content("数据有误~!请不要恶意禁用浏览器脚本~~~!"); } else { int id = Convert.ToInt32(Request.Params["Id"]); String datetime = Request.Params["OrderDate"]; String status = Request.Params["Status"]; int customerId = Convert.ToInt32(Request.Params["CustomerId"]); MyOrder updated_order = (from x in db.MyOrders where x.Id == id select x).FirstOrDefault(); updated_order.OrderDate = Convert.ToDateTime(datetime); updated_order.Status = status; updated_order.CustomerId = customerId; db.SaveChanges(); return Redirect("/Order/Index"); } }