示例#1
0
        /// <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);
        }
示例#2
0
        /// <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);
        }
示例#3
0
        /// <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(GetMessageOfNullWhiteSpace(nameof(param.IsoCode)), nameof(param));
            }
            if (param.CultureInfo == null)
            {
                throw new ArgumentException(GetMessageOfNull(nameof(param.CultureInfo)), nameof(param));
            }

            var regions = await CountryRepository.RetrieveRegions(param).ConfigureAwait(false);

            var regionsCountryModel = regions.Select(region => ViewModelMapper.MapTo <RegionViewModel>(region, param.CultureInfo));

            return(regionsCountryModel);
        }