Exemplo n.º 1
0
 public ActionResult Index()
 {
    
     ShoppingCart cart = new ShoppingCart(calc) { Products = products };
     decimal totalValue = cart.CalculateProductTotal();
     return View(totalValue );
 }
Exemplo n.º 2
0
        public ActionResult Index()
        {
            //IValueCalculator calc = new LinqValueCalculator(); //Doesn't use IKernel DI container,
                                                                 //tight-couples HomeController and LinqValueCalculator class (bad!)

            ShoppingCart cart = new ShoppingCart( calc ) { Products = products };
            decimal totalValue = cart.CalculateProductTotal();
            return View(totalValue);
        }
Exemplo n.º 3
0
        // GET: Home
        public ActionResult Index()
        {
            LinqValueCalculator calc = new LinqValueCalculator();

            ShoppingCart cart = new ShoppingCart(calc) { Products = this.products };

            decimal totalValue = cart.CalculateProductTotal();

            return View(totalValue);
        }
 // GET: Home
 public ActionResult Index() {
     //this was rendered obsolete by Infrastructure.NinjectDependencyResolver.cs
         //and the private IValueCalculator in HomeController
         //and the...I think I overloaded the HomeController just above here
     /*IKernel ninjectKernel = new StandardKernel();
     ninjectKernel.Bind<IValueCalculator>().To<LinqValueCalculator>();
     IValueCalculator calc = ninjectKernel.Get<IValueCalculator>();*/
     ShoppingCart cart = new ShoppingCart(calc) { Products = products };
     decimal totalValue = cart.CalculateProductTotal();
     return View(totalValue);
 }
Exemplo n.º 5
0
        // GET: Home
        public ActionResult Index()
        {
            //IKernel ninjectKernel = new StandardKernel();
               // ninjectKernel.Bind<IValueCalculator>().To<LinqValueCalculator>();
            //ninjectKernel.Bind<IDiscountHelper>().To<DefaultDiscountHelper>().WithConstructorArgument("discountParam", 50M);

               // IValueCalculator calc = ninjectKernel.Get<IValueCalculator>();

            ShoppingCart cart = new ShoppingCart(calc) { Products = products };

            decimal totalValue = cart.CalculateProductTotal();

            return View(totalValue);
        }
Exemplo n.º 6
0
        public ActionResult Index()
        {
            // stage 1
            //IValueCalculator calc = new LinqValueCalculator();

            // stage 2
            //IKernel ninjectKernel = new StandardKernel();
            //ninjectKernel.Bind<IValueCalculator>().To<LinqValueCalculator>();
            //IValueCalculator calc = ninjectKernel.Get<LinqValueCalculator>();

            ShoppingCart cart = new ShoppingCart(calc) { Products = products };
            decimal totalValue = cart.CalculateProductTotal();
            return View(totalValue);
        }
Exemplo n.º 7
0
        // GET: Home
        public ActionResult Index()
        {
            //create instance of ninject kernel
            //its the object responsible for resolving dependencies and creating new object
            //IKernel ninjectKernel = new StandardKernel();

            //lets MVC know that IValueCalcultor is implementing the LinqValueCalculator class
            //Dependencies on the IValueCalculator interface shuld be resolved by creating an instace of the LinqValueCalculator Class
            //ninjectKernel.Bind<IValueCalculator>().To<LinqValueCalculator>();

            //ninject creates the calc object
            //Get parameter tells ninject what interface I;m interested in
            //this returns an instance of the class object inthe To method above : LinqValueCalculator
            //IValueCalculator calc = ninjectKernel.Get<IValueCalculator>();
            ShoppingCart cart = new ShoppingCart(calc) { Products = products };
            decimal totalValue = cart.CalculateProductTotal();
            return View(totalValue);
        }
 //
 // GET: /Home/
 public ActionResult Index()
 {
     var cart = new ShoppingCart(calculator) { Products = products };
     var totalValuee = cart.CalculateProductTotal();
     return View(totalValuee);
 }