public void Update(Order order) { using (var db = new OrderDB()) { db.Order.Attach(order); db.Entry(order).State = EntityState.Modified; order.Items.ForEach( item => db.Entry(item).State = EntityState.Modified); db.SaveChanges(); } }
public bool addOrder(Order order) { try { context.Entry(order).State = EntityState.Added; context.SaveChanges(); return(true); } catch (DbUpdateException e) { return(false); } }
private void toolBar_btnEdit_Click(object sender) { if (production_orderDataGrid.SelectedItem != null) { production_order production_order = (production_order)production_orderDataGrid.SelectedItem; production_order.IsSelected = true; production_order.State = EntityState.Modified; OrderDB.Entry(production_order).State = EntityState.Modified; } else { toolBar.msgWarning("Please Select an Item"); } }
public ActionResult <OrderItem> Put(String id, OrderItem item) { if (id != item.Id) { return(BadRequest()); } db.Entry(item).State = EntityState.Modified; db.SaveChanges(); return(NoContent()); }