1
0
mirror of https://github.com/rudollee/LearningMVC.git synced 2026-08-11 16:32:55 +00:00
EssentialTools
Ninject
This commit is contained in:
wook
2017-04-04 23:28:37 +09:00
parent 7c004e28e1
commit 0eaa6708fe
21 changed files with 696 additions and 1 deletions
@@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using EssentialTools.Models;
namespace EssentialTools.Controllers
{
public class HomeController : Controller
{
private IValueCalculator calc;
private Product[] products =
{
new Product {Name = "Kayak", Category = "Watersports", Price = 275M },
new Product {Name = "Lifejacket", Category = "Watersports", Price = 48.95M},
new Product {Name = "Soccer ball", Category = "Soccer", Price = 19.50M },
new Product {Name = "Coner flag", Category = "Soccer", Price = 34.95M }
};
public HomeController(IValueCalculator calcParam)
{
calc = calcParam;
}
public ActionResult Index()
{
//LinqValueCalculator calc = new LinqValueCalculator();
//IValueCalculator calc = new LinqValueCalculator();
//IKernel ninjectKernel = new StandardKernel();
//ninjectKernel.Bind<IValueCalculator>().To<LinqValueCalculator>();
//IValueCalculator calc = ninjectKernel.Get<IValueCalculator>();
ShoppingCart cart = new ShoppingCart(calc)
{
Products = products
};
decimal totalValue = cart.CalculatorProdutTotal();
return View(totalValue);
}
}
}