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