public OrderController(IOrdersRepository ordersRepository, IOrderFormValidator orderFormValidator, IOrderFormHandler orderFormHandler, AutoShopCart autoShopCart) { this.ordersRepository = ordersRepository; this.orderFormValidator = orderFormValidator; this.orderFormHandler = orderFormHandler; this.autoShopCart = autoShopCart; }
// 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 <AutoShopDbContext>(options => options.UseSqlServer(configuration .GetConnectionString("DefaultConnection"))); services.AddScoped <IModelStateViewModelBuilder, ModelStateViewModelBuilder>(); services.AddScoped <IOrderFormValidator, OrderFormValidator>(); services.AddScoped <IOrderFormHandler, OrderFormHandler>(); services.AddTransient <ICarsRepository, CarsRepository>(); services.AddTransient <ICarCategoriesRepository, CategoriesRepository>(); services.AddTransient <IOrdersRepository, OrdersRepository>(); services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>(); services.AddScoped(sp => AutoShopCart.GetCart(sp)); services.AddHttpClient(); services.AddMvc(); services.AddMemoryCache(); services.AddSession(); services.AddControllersWithViews(mvcOptions => { mvcOptions.EnableEndpointRouting = false; }); }
public OrderRepository(AutoShopDbContext autoShopDbContext, AutoShopCart autoShopCart) { this.autoShopDbContext = autoShopDbContext; this.autoShopCart = autoShopCart; }
public AutoShopCartController(ICarsRepository carRepository, AutoShopCart autoShopCart) { this.carRepository = carRepository; this.autoShopCart = autoShopCart; }