/// <summary> /// Why is this here? Because if it isn't you get a whiny complaint from the /// ASP.NET gadget complaining that it can't find a parameterless /// constructor for this object (necessary to make IDisposable happy). /// </summary> //public HomeController() // : this(new ShoppingCart(new LinqValueCalculator(new DiscountHelper()))) //{ // // Nothing else needed here. //} public ActionResult Index() { // Original without DI //ILinqValueCalculator vCalc = new LinqValueCalculator(); //ShoppingCart vCart = // new ShoppingCart(vCalc) // { // Products = _Products // }; //decimal vTotalValue = vCart.CalculateProductTotal(); // With single layer DI //decimal vTotalValue = _ShoppingCart.CalculateProductTotal(); // With chained DI //decimal vTotalValue = _ShoppingCart.CalculateDiscountedProductTotal(); IndexViewDTO vIndexViewDTO = new IndexViewDTO { FullPrice = _ShoppingCart.CalculateProductTotal() , DiscountedPrice = _ShoppingCart.CalculateDiscountedProductTotal() }; return(View(vIndexViewDTO)); }
// GET: Home public ActionResult Index() { var totalValue = _shoppingCart.CalculateProductTotal(_products); return(View(totalValue)); }
public ActionResult Index() { decimal totalValue = cart.CalculateProductTotal(); return(View(totalValue)); }