public ShoppingCartService(IProductService productService, IDeliveryCostCalculatorService deliveryCostCalculatorService, ICampaignService campaignService) { ProductService = productService; DeliveryCostCalculatorService = deliveryCostCalculatorService; CampaignService = campaignService; cart = new Models.ShoppingCart(); }
public double CalculateDeliveryCost(Models.ShoppingCart cart) { if (!cart.Items.Any()) { return(0); } var numberOfDeliveries = cart.Items.Select(i => i.Product.CategoryTitle).Distinct().Count(); var numberOfProducts = cart.Items.Select(i => i.Product.Title).Distinct().Count(); return((numberOfDeliveries * CostPerDelivery) + (numberOfProducts * CostPerProduct) + FixedCost); }