// 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(); }
public OrderRepository(AppDbContext appDbContext, ShopppingCart shoppingCart) { _appDbContext = appDbContext; _shoppingCart = shoppingCart; }
public ShoppingCartSummary(ShopppingCart shopppingCart) { _shoppingcart = shopppingCart; }
public OrderController(IOrderRepository orderRepository, ShopppingCart shoppingCart) { _orderRepository = orderRepository; _shoppingCart = shoppingCart; }
public ShoppingCartController(IDrinkRepository drinkRepository, ShopppingCart shoppingCart) { _drinkRepository = drinkRepository; _shoppingCart = shoppingCart; }