public IController ResolveHomeController() { var connStr = ConfigurationManager .ConnectionStrings["CommerceObjectContext"] .ConnectionString; var repository = new SqlDiscountRepository(connStr); var discountCampaign = new DiscountCampaign(repository); var discountPolicy = new RepositoryBasketDiscountPolicy(repository); return new HomeController(discountCampaign, discountPolicy); }
protected virtual DiscountRepository ResolveDiscountRepository() { var repository = HttpContext.Current .Items["DiscountRepository"] as DiscountRepository; if (repository == null) { var connStr = ConfigurationManager .ConnectionStrings["CommerceObjectContext"] .ConnectionString; repository = new SqlDiscountRepository(connStr); HttpContext.Current .Items["DiscountRepository"] = repository; } return repository; }