/// <summary> /// Adds a new Order /// </summary> public static Int32 AddOrder(MVVM.DataAccess.Order newOrder) { MVVM_DemoDataContext context = new MVVM_DemoDataContext(); context.Orders.InsertOnSubmit(newOrder); context.SubmitChanges(); return(newOrder.OrderId); }
/// <summary> /// Updates an existing Order /// </summary> public static Boolean UpdateOrder(MVVM.DataAccess.Order newOrder) { MVVM_DemoDataContext context = new MVVM_DemoDataContext(); var orderToUpdate = context.Orders.Where(o => o.OrderId == newOrder.OrderId) .SingleOrDefault(); //update the values orderToUpdate.CustomerId = newOrder.CustomerId; orderToUpdate.Quantity = newOrder.Quantity; orderToUpdate.ProductId = newOrder.ProductId; orderToUpdate.DeliveryDate = newOrder.DeliveryDate; context.SubmitChanges(); return(true); }