コード例 #1
0
 /// <summary>
 /// Intended to be used to set a store's stock equal to current stocks in DB
 /// </summary>
 /// <param name="selectedStore">The store who's orders you want.</param>
 void IDbRepository.UpdateAndOverwriteStoreStocks(Store.Location selectedStore)
 {
     foreach (Invintory inv in _context.Invintories.Where(x => x.StoreLocation == selectedStore.LocationName))
     {
         if (inv.Quantity != selectedStore.CheckStock(inv.ItemName))
         {
             try
             {
                 selectedStore.SetItemStock(inv.ItemName, inv.Quantity);
             }
             catch (ItemNotFoundException e)
             {
                 _logger.LogWarning($"Item - {inv.ItemName} not found in order, adding and retrying");
                 addMissingItems(_context);
                 selectedStore.SetItemStock(inv.ItemName, inv.Quantity);
             }
         }
     }
 }
コード例 #2
0
        /// <summary>
        /// Intended to be used to set a store's stock equal to current stocks in DB
        /// </summary>
        /// <param name="selectedStore"></param>
        void IDbRepository.UpdateAndOverwriteStoreStocks(Store.Location selectedStore)
        {
            using MyStoreDbContext context = this.ConnectToDB();

            foreach (Invintory inv in context.Invintories.Where(x => x.StoreLocation == selectedStore.LocationName))
            {
                if (inv.Quantity != selectedStore.CheckStock(inv.ItemName))
                {
                    try
                    {
                        selectedStore.SetItemStock(inv.ItemName, inv.Quantity);
                    }
                    catch (ItemNotFoundException e)
                    {
                        addMissingItems(context);
                        selectedStore.SetItemStock(inv.ItemName, inv.Quantity);
                    }
                }
            }
        }