public Order GetOrder(string Id) { using (var db = new OrderDB()) { return(db.Order.Include("Items"). SingleOrDefault(o => o.OrderID == Id)); } }
public void DeleteDB(string orderId) { using (var db = new OrderDB()) { var order = db.Order.Include("Items").SingleOrDefault(o => o.OrderID == orderId); db.OrderItem.RemoveRange(order.Items); db.Order.Remove(order); db.SaveChanges(); } }
public void AddOrderDB(Order order) { using (var db = new OrderDB()) { db.Order.Add(order); //db.Order.Attach(order); //db.Entry(order).State = EntityState.Added; db.SaveChanges(); } }
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 void AddOrderEF(Order order) { using (OrderDB db = new OrderDB()) { try { db.Order.Add(order); //db.Order.Attach(order); //db.Entry(order).State = EntityState.Added; db.SaveChanges(); } catch (Exception ex) { } } }
public void UpdateList() { using (var db = new OrderDB()) { this.Orders = db.Order.Include("items").ToList <Order>(); } }