Пример #1
0
        public decimal GetCartTotal()
        {
            var cartTotal = 0M;

            foreach (var product in _products)
            {
                try
                {
                    cartTotal += ValidateProduct(product);
                    _shipping.CreateShippingRequest();
                }
                catch (ProductCostZeroOrLessException e)
                {
                    Console.WriteLine(
                        $"The price entered for the item {e.ProductName} was less than or equal to zero. " +
                        "All product prices need to be larger than 0.");
                    throw;
                }
            }

            return(cartTotal);
        }