public static async Task RemoveCountry(CountryId id) { var connectionString = ConnectivityService.GetConnectionString("TEMP"); var context = new SplurgeStopDbContext(connectionString); var repository = new CountryRepository(context); var unitOfWork = new EfCoreUnitOfWork(context); var service = new CountryService(repository, unitOfWork); var countryController = new CountryController(service); var updateCommand = new Commands.DeleteCountry { Id = id }; await countryController.DeleteCountry(updateCommand); }
public async Task <ActionResult <CountryDeleted> > DeleteCountry(Commands.DeleteCountry request) { var result = await RequestHandler.HandleCommand(request, _service.Handle); if (result.GetType() == typeof(OkResult)) { return new CountryDeleted { Id = request.Id } } ; else { return(new BadRequestObjectResult(new { error = "Error occurred during delete attempt." })); } }