public static void Update(EditableOrder order) { EditableOrder editable = One(o => o.OrderID == order.OrderID); if (editable != null) { editable.OrderDate = order.OrderDate; editable.Employee = order.Employee; editable.Freight = order.Freight; } }
public ActionResult UpdateOrder(int id, int employee) { EditableOrder order = new EditableOrder { OrderID = id, Employee = new NorthwindDataContext().Employees.SingleOrDefault(e => e.EmployeeID == employee) }; // Exclude "Employee" from the list of updated properties if (TryUpdateModel(order, null, null, new [] { "Employee" })) { SessionOrderRepository.Update(order); return RedirectToAction("ServerEditTemplates", this.GridRouteValues()); } PopulateEmployees(); return View("ServerEditTemplates", SessionOrderRepository.All()); }