Пример #1
0
 bool ControlToy(Classes.Order order, List <Toy> toys)
 {
     foreach (var toy in toys)
     {
         int toyCount = 0;
         foreach (var toyOrder in order.Toys)
         {
             if (toy.Name.Equals(toyOrder.Name))
             {
                 toyCount++;
             }
         }
         if (toy.Amount < toyCount)
         {
             return(false);
         }
     }
     return(true);
 }
Пример #2
0
        private void checkStorageAvailability(Classes.Order orderToControl)
        {
            Models.Order model = new Models.Order();
            model.OrderedToys = populateToysList(orderToControl.Toys);
            bool isOrderedEditable = true;

            foreach (OrderedToy toy in model.OrderedToys)
            {
                if (toy.DesiredQuantity > toy.Amount)
                {
                    isOrderedEditable = false;
                }
            }

            if (!isOrderedEditable)
            {
                throw new NotEnoughToysInStorageException("There are no enough toys in the storage. Check order details for more info");
            }
        }
Пример #3
0
        List <Toy> MissingToy(Classes.Order order, List <Toy> toys)
        {
            List <Toy> missingToy = new List <Toy>();

            foreach (var toy in toys)
            {
                int toyCount = 0;
                foreach (var toyOrder in order.Toys)
                {
                    if (toy.Name.Equals(toyOrder.Name))
                    {
                        toyCount++;
                    }
                }
                if (toy.Amount < toyCount)
                {
                    missingToy.Add(toy);
                }
            }
            return(missingToy);
        }