ResolveProductManagementService()
 {
     ProductRepository repository =
         new SqlProductRepository(
             this.connectionString);
     return new ProductManagementService(
         repository, this.mapper);
 }
		public IProductManagementService ResolveProductManagementService()
		{
			var repository = new SqlProductRepository(this.connectionString);
			var srvc = new ProductManagementService(repository, this.mapper);

			lock (this.syncRoot)
			{
				this.repositories.Add(srvc, repository);
			}

			return srvc;
		}
        public IProductManagementService ResolveProductManagementService()
        {
            string connectionString =
                ConfigurationManager.ConnectionStrings
                ["CommerceObjectContext"].ConnectionString;

            ProductRepository repository =
                new SqlProductRepository(connectionString);

            IContractMapper mapper = new ContractMapper();

            return new ProductManagementService(repository, 
                mapper);
        }
        protected override IController GetControllerInstance(
            RequestContext requestContext, Type controllerType)
        {
            string connectionString =
                ConfigurationManager.ConnectionStrings
                ["CommerceObjectContext"].ConnectionString;

            var productRepository =
                new SqlProductRepository(connectionString);
            var basketRepository =
                new SqlBasketRepository(connectionString);
            var discountRepository =
                new SqlDiscountRepository(connectionString);

            var discountPolicy =
                new RepositoryBasketDiscountPolicy(
                    discountRepository);

            var basketService =
                new BasketService(basketRepository,
                    discountPolicy);

            var currencyProvider = new CachingCurrencyProvider(
                new SqlCurrencyProvider(connectionString),
                TimeSpan.FromHours(1));

            if (controllerType == typeof(BasketController))
            {
                return new BasketController(
                    basketService, currencyProvider);
            }
            if (controllerType == typeof(HomeController))
            {
                return new HomeController(
                    productRepository, currencyProvider);
            }

            return base.GetControllerInstance(
                requestContext, controllerType);
        }