Ejemplo n.º 1
0
        public async Task PerformStockRequest(StockRequest s)
        {
            var ownerItem = await _context.OwnerInventory.
                            SingleOrDefaultAsync(r => r.ProductID == s.ProductID);

            var storeItem = await _context.StoreInventory.
                            Where(r => r.StoreID == s.StoreID).
                            SingleOrDefaultAsync(r => r.ProductID == s.ProductID);

            //Add product to store if not currently in Inventory.
            if (storeItem == null)
            {
                StoreInventory item = new StoreInventory {
                    StoreID = s.StoreID, ProductID = s.ProductID, StockLevel = s.Quantity
                };
                _context.StoreInventory.Add(item);
                await _context.SaveChangesAsync();
            }
            else
            {
                storeItem.StockLevel += s.Quantity;
            }

            //Decrease owner product stock level.
            ownerItem.StockLevel -= s.Quantity;

            // Remove stock request
            _context.StockRequests.Remove(s);

            await _context.SaveChangesAsync();
        }
Ejemplo n.º 2
0
        public async Task <bool> IsStockAvailable(StockRequest s)
        {
            var query = await GetOwnerInventory(s.ProductID);

            OwnerInventory item = query.First();
            var            test = item.StockLevel;

            return(item.StockLevel >= s.Quantity);
        }
Ejemplo n.º 3
0
        public async Task AddItemToStoreInventory(StockRequest s)
        {
            //Add item to storeInventory
            StoreInventory item = new StoreInventory {
                StoreID = this.StoreID, ProductID = s.ProductID, StockLevel = s.Quantity
            };

            this._context.StoreInventory.Add(item);
            this._context.SaveChanges();
            return;
        }
Ejemplo n.º 4
0
 public async void MakeStockRequest(StockRequest s)
 {
     return;
 }