Beispiel #1
0
 public Order GetOrder(string Id)
 {
     using (var db = new OrderDB()) {
         return(db.Order.Include("Items").
                SingleOrDefault(o => o.OrderID == Id));
     }
 }
Beispiel #2
0
 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();
     }
 }
Beispiel #3
0
 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();
     }
 }
Beispiel #4
0
 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();
     }
 }
Beispiel #5
0
 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) {                }
     }
 }
Beispiel #6
0
 public void UpdateList()
 {
     using (var db = new OrderDB()) {
         this.Orders = db.Order.Include("items").ToList <Order>();
     }
 }