Пример #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDbContext <AppDbContext>(options =>
                                                 options.UseSqlServer(_configurationRoot.GetConnectionString("DefaultConnection")));

            //Authentication, Identity config
            services.AddIdentity <IdentityUser, IdentityRole>()
            .AddEntityFrameworkStores <AppDbContext>();



            services.AddTransient <IDrinkRepository, DrinkRepository>();
            services.AddTransient <ICategoryRepository, CategoryRepository>();
            services.AddTransient <IOrderRepository, OrderRepository>();

            services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();
            services.AddScoped(sp => ShopppingCart.GetCart(sp));
            services.AddControllersWithViews();
            services.AddMvc();
            services.AddMemoryCache();
            services.AddSession();
        }