Пример #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 http://go.microsoft.com/fwlink/?LinkID=398940
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddDbContext <AppDbContext>(options => options.UseSqlServer(_configurationRoot.GetConnectionString("DefaultConnection")));
     services.AddIdentity <IdentityUser, IdentityRole>().AddEntityFrameworkStores <AppDbContext>();
     services.AddTransient <IDrink, DrinkRepository>();
     services.AddTransient <ICategory, CategoryRepository>();
     services.AddTransient <IShopingCart, ShopingCartRepository>();
     services.AddTransient <IOrder, OrderRepository>();
     services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();
     services.AddScoped(sp => ShopingCard.GetCart(sp));
     services.AddMvc();
     services.AddMemoryCache();
     services.AddSession();
 }