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