private bool isCountryValid(string name) { if (!string.IsNullOrEmpty(name)) { var country = client.GetCountry(name); return(!string.IsNullOrEmpty(country.Result) ? true : false); } return(false); }
public async Task <bool> CountryExists(string countryName) { // ToDo Redis is better to multiple APIs var country = _cacheProvider.GetFromCache <Country>(countryName); if (country != null) { return(true); } var response = await _countryClient.GetCountry(countryName); if (response.IsSuccessStatusCode) { _cacheProvider.SetValue(countryName, new Country() { Name = countryName }); return(true); } return(false); }