Пример #1
0
 public async static Task GetAllProducts()
 {
     Products.Clear();
     Categories.Clear();
     ProductPrices.Clear();
     Stores.Clear();
     GoodsReceipts.Clear();
     using (var db = new SalesContext())
     {
         try
         {
             var result  = await(from c in db.Products select c).Include("ProductPrices").ToListAsync();
             var result1 = await(from c in db.Categories.Include("Products") select c).ToListAsync();
             var result2 = await(from c in db.ProductPrices select c).Include("Product").Include("Store").ToListAsync();
             var result3 = await(from c in db.Stores select c).Include("ProductPrices").ToListAsync();
             var result4 = await(from c in db.GoodsReceipts select c).Include("ReceiptDetails").Include("Store").ToListAsync();
             foreach (Product item in result)
             {
                 Products.Add(item);
             }
             foreach (Category item in result1)
             {
                 Categories.Add(item);
             }
             foreach (ProductPrice item in result2)
             {
                 ProductPrices.Add(item);
             }
             foreach (Store item in result3)
             {
                 Stores.Add(item);
             }
             foreach (GoodsReceipt item in result4)
             {
                 GoodsReceipts.Add(item);
             }
         }
         catch (Exception e)
         {
             var x = e.Message;
         }
     }
 }
Пример #2
0
        public async static Task AddProductPrice(ProductPrice itemPara)
        {
            using (var db = new SalesContext())
            {
                if (itemPara.Store != null)
                {
                    itemPara.StoreID         = itemPara.Store.Id;
                    itemPara.ProductID       = itemPara.Product.Id;
                    db.Entry(itemPara).State = EntityState.Unchanged;
                }
                db.ProductPrices.Add(itemPara);
                await UpdateDatabase(db);

                CodeGenerate(itemPara);
                await UpdateDatabase(db);

                ProductPrices.Add(itemPara);
            }
        }
Пример #3
0
 public void AddPrice(int id, int?price)
 {
     ProductPrices.Add(id, price);
 }