Example #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDbContext <AppDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("SportsStore")));
            services.AddDbContext <AppIdentityDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("SportsStoreIdentity")));

            services.AddIdentity <IdentityUser, IdentityRole>().AddEntityFrameworkStores <AppIdentityDbContext>().AddDefaultTokenProviders();

            services.AddTransient <IProductRepository, EFProductRepository>();
            services.AddTransient <IOrderRepository, EFOrderRepository>();

            services.AddScoped <ICartService, CartService>(sp => SessionCartService.GetCartService(sp));
            services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();

            services.AddControllersWithViews();
            services.AddMemoryCache();
            services.AddSession();

            services.AddAutoMapper(Assembly.GetExecutingAssembly());
        }
 public CartController(IBouquetManager bouquetManager,
                       SessionCartService sessionCartService)
 {
     this.bouquetManager     = bouquetManager;
     this.sessionCartService = sessionCartService;
 }