public LocationRepository( HttpClient httpClient, PostcodeFileImporter postcodeFileImporter ) { this.httpClient = httpClient; this.postcodeFileImporter = postcodeFileImporter; postcodeIOUrl = Environment.GetEnvironmentVariable("POSTCODES_IO_URL") ?? "http://localhost:8000/postcodes"; }
private static async Task <Response> GetLocations() { using (var httpClient = new HttpClient()) { string fullPath = System.Reflection.Assembly.GetAssembly(typeof(Program)).Location; string directory = Path.GetDirectoryName(fullPath); var filePath = $"{directory}/assets/postcodes.txt"; var importer = new PostcodeFileImporter(filePath); var repo = new LocationRepository(httpClient, importer); return(await repo.GetLocations()); } }