Exemplo n.º 1
0
        //The method that raises the OutOfStorageEvent
        protected void RaiseOutOfStorageEvent(OutOfStorageEventArgs e)
        {
            OutOfStorageEventHandler handler = OutOfStorageEvent;

            if (handler != null)
            {
                handler(this, e);
            }
        }
Exemplo n.º 2
0
        //Keeps a list of all the products that are out of storage
        void OutOfStorageManagement(object sender, OutOfStorageEventArgs args)
        {
            int allStorageStock = 0;

            for (int i = 0; i < allStorages.Count; i++)
            {
                if (allStorages[i] != sender)
                {
                    allStorageStock += allStorages[i].GetStock(args.ProductId);
                }
            }

            if (allStorageStock == 0)
            {
                outOfStorage.Add(args.ProductId);
                throw new InsufficientStockException <int>(args.ProductId, args.RemainingQuantity);
            }
        }