Esempio n. 1
0
 public List <Order> GetAllOrders()
 {
     using (var data_1 = new ordersql())
     {
         return(data_1.Order.Include("Details").ToList <Order>());
     }
 }
Esempio n. 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));
     }
 }
Esempio n. 3
0
 public void Add(Order order)
 {
     using (var data_1 = new ordersql())
     {
         data_1.Order.Add(order);
         data_1.SaveChanges();
     }
 }
Esempio n. 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();
     }
 }
Esempio n. 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();
     }
 }