// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { var carRepository = new CarFileRepository("cars.json"); var clientRepository = new ClientRepository("clients.json"); var idProvider = IdProvider.CreateIdProvider(carRepository, clientRepository); var setting = new CarRentSettings(Configuration.GetValue <int>("MaxRentsWithoutCheckup"), Configuration.GetValue <TimeSpan>("CheckupTime")); var administratorCarRental = new AdministratorCarRental(carRepository, idProvider); var clientCarRental = new ClientCarRental(carRepository, clientRepository, idProvider, setting); services.AddSingleton <IAdministratorCarRental>(administratorCarRental); services.AddSingleton <IClientCarRental>(clientCarRental); ConfigureSecurity(services); services.AddMvc(o => o.Filters.Add(new ExceptionFilter())); }