// GET: /<controller>/ public IActionResult Index() { OffersViewModel model = _offersService.GetOffers(); ViewData["OfferTitle"] = "Offers"; return(View(model)); }
public decimal GetTotalCost() { decimal totalCost = 0; var pairs = cartItems.ToList(); foreach (var(productId, cartItem) in pairs) { var unitPrice = priceService.GetActualPrice(productId, cartItem.DateCreated); var offers = offersService.GetOffers(productId); if (!offers.Any()) { totalCost += unitPrice * cartItem.Quantity; continue; } totalCost += offersCalculator.CalculateCost(offers, cartItem.Quantity, unitPrice); } return(totalCost); }