/// <summary> /// Retrieve the display name for a specified region. /// </summary> /// <param name="param"></param> /// <returns></returns> public virtual async Task <string> RetrieveRegionDisplayNameAsync(RetrieveRegionDisplayNameParam param) { if (param == null) { throw new ArgumentNullException("param"); } if (param.CultureInfo == null) { throw new ArgumentException("param.CultureInfo"); } if (string.IsNullOrWhiteSpace(param.IsoCode)) { throw new ArgumentException("param.IsoCode"); } if (string.IsNullOrWhiteSpace(param.RegionCode)) { throw new ArgumentException("param.RegionCode"); } var retrieveCountryParam = new RetrieveCountryParam { CultureInfo = param.CultureInfo, IsoCode = param.IsoCode }; var regions = await RetrieveRegionsAsync(retrieveCountryParam).ConfigureAwait(false); var region = regions.SingleOrDefault(r => r.IsoCode == param.RegionCode); return(region != null ? region.Name : string.Empty); }
/// <summary> /// Retrieve a list of regions for a specified country using its ISO code /// </summary> /// <param name="param"></param> /// <returns>A list of Region</returns> public async Task <IEnumerable <Region> > RetrieveRegions(RetrieveCountryParam param) { if (string.IsNullOrWhiteSpace(param.IsoCode)) { throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.IsoCode)), nameof(param)); } if (param.CultureInfo == null) { throw new ArgumentException(GetMessageOfNull(nameof(param.CultureInfo)), nameof(param)); } var regionsCacheKey = new CacheKey(CacheConfigurationCategoryNames.Regions) { CultureInfo = param.CultureInfo }; regionsCacheKey.AppendKeyParts(param.IsoCode); var result = await _cacheProvider.GetOrAddAsync(regionsCacheKey, () => { var request = new GetRegionsRequest { CountryIsoCode = param.IsoCode, CultureName = param.CultureInfo.Name, IncludeUnsupported = false }; return(_overtureClient.SendAsync(request)); }).ConfigureAwait(false); return(result); }
/// <summary> /// Retrieve the CountryViewModel /// </summary> /// <param name="param"></param> /// <returns></returns> public virtual async Task <CountryViewModel> RetrieveCountryAsync(RetrieveCountryParam param) { if (string.IsNullOrWhiteSpace(param.IsoCode)) { throw new ArgumentException(ArgumentNullMessageFormatter.FormatErrorMessage("IsoCode"), "param"); } var country = await CountryRepository.RetrieveCountry(param).ConfigureAwait(false); var countryViewModel = ViewModelMapper.MapTo <CountryViewModel>(country, param.CultureInfo); return(countryViewModel); }
/// <summary> /// Retrieve the CountryViewModel /// </summary> /// <param name="param"></param> /// <returns></returns> public virtual async Task <CountryViewModel> RetrieveCountryAsync(RetrieveCountryParam param) { if (string.IsNullOrWhiteSpace(param.IsoCode)) { throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.IsoCode)), nameof(param)); } var country = await CountryRepository.RetrieveCountry(param).ConfigureAwait(false); var countryViewModel = ViewModelMapper.MapTo <CountryViewModel>(country, param.CultureInfo); return(countryViewModel); }
public virtual async Task <string> RetrieveCountryDisplayNameAsync(RetrieveCountryParam param) { if (param == null) { throw new ArgumentNullException("param"); } if (param.CultureInfo == null) { throw new ArgumentException("param.CultureInfo"); } if (string.IsNullOrWhiteSpace(param.IsoCode)) { throw new ArgumentException("param.IsoCode"); } var country = await RetrieveCountryAsync(param).ConfigureAwait(false); return(country != null ? country.CountryName : string.Empty); }
/// <summary> /// Retrieve a country using its ISO code /// </summary> /// <param name="param"></param> /// <returns></returns> public async Task <Overture.ServiceModel.Country> RetrieveCountry(RetrieveCountryParam param) { if (string.IsNullOrWhiteSpace(param.IsoCode)) { throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.IsoCode)), nameof(param)); } var countryCacheKey = new CacheKey(CacheConfigurationCategoryNames.Country); countryCacheKey.AppendKeyParts(param.IsoCode); var result = await _cacheProvider.GetOrAddAsync(countryCacheKey, () => { var request = new GetCountryRequest { CountryIsoCode = param.IsoCode, IncludeRegions = true }; return(_overtureClient.SendAsync(request)); }).ConfigureAwait(false); return(result); }
/// <summary> /// Retrieve the list of RegionViewModel for a specified Country /// </summary> /// <param name="param"></param> /// <returns></returns> public virtual async Task <IEnumerable <RegionViewModel> > RetrieveRegionsAsync(RetrieveCountryParam param) { if (string.IsNullOrWhiteSpace(param.IsoCode)) { throw new ArgumentException(ArgumentNullMessageFormatter.FormatErrorMessage("IsoCode"), "param"); } if (param.CultureInfo == null) { throw new ArgumentException(ArgumentNullMessageFormatter.FormatErrorMessage("CultureInfo"), "param"); } var regions = await CountryRepository.RetrieveRegions(param).ConfigureAwait(false); var regionsCountryModel = regions.Select(region => ViewModelMapper.MapTo <RegionViewModel>(region, param.CultureInfo)); return(regionsCountryModel); }