/// <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)); }
public ActionResult Index(int?page) { int pageSize = 7; var goods = goodManager.GetAll(); var categories = categoryManager.GetAll(); var goods_list = goodManager.GetAll(); foreach (var item in goods_list) { item.Category = categoryManager.Get(item.Category_Id); item.WebShop = shopManager.GetById(item.WebShop_Id); } int pageNumber = (page ?? 1); var Custom_model = new IndexViewDTO() { CategoryList = categories, GoodList = goods_list.ToPagedList(pageNumber, pageSize) }; ModelState.Clear(); return(View(Custom_model)); }