public async Task <List <Country> > GetAllCountries()
        {
            var            request   = new CountriesRequest(Guid.NewGuid());
            List <Country> countries = await DoRequest <List <Country> >(request);

            //берем только уникальные записи от всех провайдеров
            return(countries.GetUniqueElements(c => c.Name));
        }
Beispiel #2
0
        private async Task ReceiveCountriesRequest(CountriesRequest request)
        {
            var countries = await _dictionariesRepository.GetAllCountries();

            _messageBusClient.SendMessage(new CountriesResponse(request.RequestId, nameof(OtherSearchService))
            {
                Data = countries.Select(country => new Country
                {
                    Id   = country.Id,
                    Name = country.Name
                }).ToList()
            });
        }
Beispiel #3
0
        /// <summary>
        /// Gets the countries asynchronous.
        /// </summary>
        /// <param name="search">The search.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>IEnumerable&lt;ICountry&gt;.</returns>
        public async Task <IEnumerable <ICountry> > GetCountriesAsync(string search, CancellationToken cancellationToken)
        {
            var request = new CountriesRequest {
                Key = _apiKey
            };

            if (!string.IsNullOrWhiteSpace(search))
            {
                request.Search = search;
            }

            var response = await Execute <CountriesRequest, CountriesResponse>(request, cancellationToken).ConfigureAwait(false);

            return(response.Countries);
        }