Ejemplo n.º 1
0
        private async Task UpdateContryInfoAsync(CityInfoDto cityDto)
        {
            if (string.IsNullOrWhiteSpace(cityDto.Country))
            {
                return;
            }
            var countryInfo = await _countryInfoService.GetCountryInfoAsync(cityDto.Country);

            if (countryInfo == null || countryInfo.Count == 0)
            {
                return;
            }
            cityDto.CountryInfo = new CountryInfoDto()
            {
                Alpha2Code = countryInfo[0].Alpha2Code,
                Alpha3Code = countryInfo[0].Alpha3Code,
                Currencies = countryInfo[0].Currencies?.Select(cu => cu.Name).ToList()
            };
        }
Ejemplo n.º 2
0
        private async Task UpdateWeatherAsync(CityInfoDto cityDto)
        {
            var weatherInfo = await _weatherService.GetWeatherAsync(cityDto.Name);

            if (weatherInfo != null)
            {
                cityDto.Weather = new WeatherInfoDto()
                {
                    Description = weatherInfo.Weather?.ElementAtOrDefault(0)?.Description,
                    Humidity    = weatherInfo.Main?.Humidity,
                    Pressure    = weatherInfo.Main?.Pressure,
                    Temperature = new TemperatureDto()
                    {
                        Current   = weatherInfo.Main?.Temp,
                        FeelsLike = weatherInfo.Main?.FeelsLike,
                        Minimum   = weatherInfo.Main?.TempMin,
                        Maximum   = weatherInfo.Main?.TempMax,
                    }
                };
            }
        }