public ActionResult Update_Order(OrderViewModel order) { if (order != null && ModelState.IsValid) { var target = GetOrderByID(order.OrderID); target.ShipAddress = order.ShipAddress; target.ShipCountry = order.ShipCountry; target.ShipName = order.ShipName; target.ShippedDate = order.ShippedDate; context.SaveChanges(); } return Json(ModelState.ToDataSourceResult()); }
public ActionResult Create_Order(OrderViewModel order) { if (order != null && ModelState.IsValid) { var target = new Order(); target.ShipAddress = order.ShipAddress; target.ShipCountry = order.ShipCountry; target.ShipName = order.ShipName; target.ShippedDate = order.ShippedDate; context.Orders.AddObject(target); context.SaveChanges(); order.OrderID = target.OrderID; } return Json(new[] { order }.ToDataSourceResult(new DataSourceRequest(), ModelState)); }