コード例 #1
0
        public double Total(IList <CartItem> cart)
        {
            if (cart == null || cart.Count == 0)
            {
                return(0);
            }

            double runningTotal = 0;

            foreach (var item in cart)
            {
                var product = _productRepository.Get(item.ProductId);
                if (product != null)
                {
                    runningTotal += item.UnitQuantity * product.Price;
                }
            }

            return(runningTotal + _shippingCalculator.CalcShipping(runningTotal));
        }