Exemple #1
0
        private bool isValidProduct(List <ProductDomain> ListProducts)
        {
            string AvailableProducts = DomainBase.GetAvailableProduct();

            foreach (ProductDomain product in ListProducts)
            {
                if (!AvailableProducts.ToUpper().Contains(product.Name.ToUpper()))
                {
                    return(false);
                }
            }
            return(true);
        }
Exemple #2
0
        private bool ExecuteValidation(List <ProductDomain> ListProducts)
        {
            if (MachineDomain.InsertedCoins == null || MachineDomain.InsertedCoins.Count == 0)
            {
                throw new ValidationException("Please Insert some Coins..");
            }
            else if (!isValidProduct(ListProducts))
            {
                throw new ValidationException(String.Format("NO_PRODUCT. Please request only {0}", DomainBase.GetAvailableProduct()));
            }
            else if (!isAvailableQttProduct(ListProducts))
            {
                throw new ValidationException("Unavailable Product. Insufficient Quantity. Sorry!");
            }
            else if (!isEnoughMoney(ListProducts))
            {
                throw new ValidationException("Insufficiente Coins to order the amount of product. Please Insert more Coins.");
            }

            return(true);
        }