// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, CustomerMessageListener messageListener) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseHttpsRedirection(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); using (var serviceScope = app.ApplicationServices.GetService <IServiceScopeFactory>().CreateScope()) { var context = serviceScope.ServiceProvider.GetRequiredService <AppDataContext>(); context.Database.EnsureCreated(); } new Thread(() => { messageListener.Start(env.ContentRootPath); }).Start(); }
public CustomersController(ICommandHandler <Command> commandHandler, CustomerSQLiteRepository sqliteRepository, CustomerMongoRepository repository, CustomerMessageListener listener) { _commandHandler = commandHandler; _sqliteRepository = sqliteRepository; _mongoRepository = repository; if (_mongoRepository.GetCustomers().Count == 0) { var customerCmd = new CreateCustomerCommand { Name = "George Michaels", Email = "*****@*****.**", Age = 23, Phones = new List <CreatePhoneCommand> { new CreatePhoneCommand { Type = PhoneType.CELLPHONE, AreaCode = 123, Number = 7543010 } } }; _commandHandler.Execute(customerCmd); } }
public CustomersController(ICommandHandler <Command> commandHandler, CustomerSQLiteRepository sqliteRepository, CustomerMongoRepository repository, CustomerMessageListener listener) { _commandHandler = commandHandler; _sqliteRepository = sqliteRepository; _mongoRepository = repository; _listener = listener; //if (_mongoRepository.GetCustomers().Count == 0) //{ // var customerCmd = new CreateCustomerCommand // { // Name = "Ajay", // Email = "*****@*****.**", // Age = 23, // Phones = new List<CreatePhoneCommand> // { // new CreatePhoneCommand { Type = PhoneType.CELLPHONE, AreaCode = 123, Number = 7543010 } // } // }; // _commandHandler.Execute(customerCmd); //} }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, CustomerMessageListener messageListener) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseHsts(); } app.UseHttpsRedirection(); app.UseMvc(); using (var serviceScope = app.ApplicationServices.GetService <IServiceScopeFactory>().CreateScope()) { var context = serviceScope.ServiceProvider.GetRequiredService <CustomerSQLiteDatabaseContext>(); context.Database.EnsureCreated(); } new Thread(() => { messageListener.Start(_env.ContentRootPath); }).Start(); }