コード例 #1
0
        public decimal GetTotalPrice(IList <ProductPrice> productPrices, DiscountPolicy discountPolicy)
        {
            if (productPrices.IsEmpty())
            {
                throw new ArgumentNullException("productPrices");
            }

            IDiscountCalculator discountCalculator = _discountCalculatorFactory.Get(discountPolicy);
            decimal             totalPrice         = productPrices.Sum(x => x.Price);
            decimal             discount           = discountCalculator.Compute();

            return(totalPrice - discount);
        }