public async Task <IActionResult> GetCustomers(string firstName, string lastName) { IServiceProvider provider = TestServiceProvider.CreateProvider(); using (IServiceScope scope = provider.CreateScope()) { await SeedRepository(scope.ServiceProvider); CustomersController controller = scope.ServiceProvider.GetRequiredService <CustomersController>(); return(await controller.GetCustomers(firstName, lastName, scope.ServiceProvider.GetRequiredService <GetCustomersCommand>())); } }
public async Task <IActionResult> AddCustomer(Customer customer) { IServiceProvider provider = TestServiceProvider.CreateProvider(_setup); using (IServiceScope scope = provider.CreateScope()) { CustomersController controller = scope.ServiceProvider.GetRequiredService <CustomersController>(); IActionResult result = await controller.AddCustomer(customer, scope.ServiceProvider.GetRequiredService <AddCustomerCommand>()); await SnapshotRepository(scope.ServiceProvider); return(result); } }
public async Task <IActionResult> DeleteCustomer(string customerId) { IServiceProvider provider = TestServiceProvider.CreateProvider(); using (IServiceScope scope = provider.CreateScope()) { await SeedRepository(scope.ServiceProvider); CustomersController controller = scope.ServiceProvider.GetRequiredService <CustomersController>(); IActionResult result = await controller.DeleteCustomer(customerId, scope.ServiceProvider.GetRequiredService <DeleteCustomerCommand>()); await SnapshotRepository(scope.ServiceProvider); return(result); } }