public async Task <List <City> > GetAllCities() { var request = new CitiesRequest(Guid.NewGuid()); List <City> cities = await DoRequest <List <City> >(request); //берем только уникальные записи от всех провайдеров return(cities.GetUniqueElements(c => c.Name)); }
private static bool IsValidCityRequest(ref CitiesRequest request) { if (!request.Temperature.HasValue) { return(false); } if (request.Scale == TemperatureScales.NotSpecified) { request.Scale = TemperatureScales.Fahrenheit; } return(true); }
private async Task ReceiveCitiesRequest(CitiesRequest request) { var cities = await _dictionariesRepository.GetAllCities(); _messageBusClient.SendMessage(new CitiesResponse(request.RequestId, nameof(OtherSearchService)) { Data = cities.Select(city => new City { Id = city.Id, Name = city.Name, CountryId = city.CountryId }).ToList() }); }
/// <summary> /// Gets the cities asynchronous. /// </summary> /// <param name="stateInitials">The state initials.</param> /// <param name="token">The cancellation token.</param> /// <returns></returns> public async Task <CitiesData> GetCitiesAsync(String stateInitials, CancellationToken token) { var data = new CitiesRequest { Token = _token, StateInitials = stateInitials, }; var results = await _service.Get <City[], CitiesRequest>(data, token).ConfigureAwait(_configureAwait); return(new CitiesData { Cities = results, StateInitials = stateInitials, Success = results.Any() }); }