예제 #1
0
        //initialize store inventory from database-information.
        static void InitStoreInventory(caproj0Context context, ILocation store)
        {
            var loc = context.StoreLocation.FirstOrDefault(l => l.LocationId == store.LocID);

            //linq query to get the orders by id for location
            var invLine = from inv in context.Inventory
                          where (inv.LocationId == store.LocID)
                          select inv;

            //convert to list
            var stInv = invLine.ToList();

            //make the inventory
            //store.AddProduct(new business_logic.Product("circuits", "Sal's fine Circuits", 12.5, 300));

            for (int i = 0; i < stInv.Count; i++)
            {
                var invItem = context.Product.FirstOrDefault(q => q.ProductId == stInv[i].ProductId);

                Console.WriteLine($"Adding {stInv[i].Quantity}x{invItem.Pname}");

                store.AddProduct(new business_logic.Product(invItem.Pname, invItem.SalesName, (double)invItem.Cost, stInv[i].Quantity, stInv[i].ProductId));
            }
        }