Пример #1
0
 public List <PurchaseOrder> GetAllOpenPurchaseOrders()
 {
     using (AcmeCorpContainer ctx = new AcmeCorpContainer())
     {
         return((from order in ctx.PurchaseOrders.Include("LineItems").Include("Supplier")
                 select order).ToList());
     }
 }
Пример #2
0
 public PurchaseOrder GetPurchaseOrder(int purchaseOrderId)
 {
     using (AcmeCorpContainer ctx = new AcmeCorpContainer())
     {
         return((from order in ctx.PurchaseOrders.Include("LineItems").Include("Supplier")
                 where order.Id == purchaseOrderId
                 select order).Single());
     }
 }
Пример #3
0
        public void AddToPurchaseOrder(int purchaseOrderId, string item, int quantity, decimal price)
        {
            using (AcmeCorpContainer ctx = new AcmeCorpContainer())
            {
                PurchaseOrder order = ctx.PurchaseOrders.Where(o => o.Id == purchaseOrderId).Single();

                order.AddLineItem(new PurchaseOrderLineItem()
                {
                    Description = item, Quantity = quantity, Price = price, Position = order.Items.Count()
                });

                ctx.SaveChanges();
            }
        }