Beispiel #1
0
 public List <Order> GetAllOrders()
 {
     using (var db = new orderDB())
     {
         return(db.Order.Include("Details").ToList <Order>());
     }
 }
Beispiel #2
0
 public Order GetOrder(String Id)
 {
     using (var db = new orderDB())
     {
         return(db.Order.Include("Details").
                SingleOrDefault(o => o.Id.ToString() == Id));
     }
 }
Beispiel #3
0
 public void Add(Order order)
 {
     using (var db = new orderDB())
     {
         db.Order.Add(order);
         db.SaveChanges();
     }
 }
Beispiel #4
0
 public void Delete(String orderId)
 {
     using (var db = new orderDB())
     {
         var order = db.Order.Include("Details").SingleOrDefault(o => o.Id.ToString() == orderId);
         db.OrderDetails.RemoveRange(order.Details);
         db.Order.Remove(order);
         db.SaveChanges();
     }
 }
Beispiel #5
0
 public void Update(Order order)
 {
     using (var db = new orderDB())
     {
         db.Order.Attach(order);
         db.Entry(order).State = EntityState.Modified;
         order.Details.ForEach(
             Details => db.Entry(Details).State = EntityState.Modified);
         db.SaveChanges();
     }
 }