public void CalculateTotal(Cart cart)
        {
            cart.TotalInUsDollarsWithDiscounts = cart.Products
                                                 .Sum(product =>
            {
                var discountPrice = discountCalculator
                                    .CalculateProductDiscountForCustomer(product, cart.Customer);

                return(discountPrice * product.Quantity);
            });
        }
Exemple #2
0
        public IActionResult GetProductDiscountPrice(Guid productId, string customerLogin)
        {
            var product  = unitOfWork.ProductRepository.GetProductById(productId);
            var customer = unitOfWork.CustomerRepository.GetCustomerByLogin(customerLogin);

            if (product == null || customer == null)
            {
                return(BadRequest());
            }

            var discountPrice = discountCalculator.CalculateProductDiscountForCustomer(product, customer);

            return(Ok(discountPrice));
        }