public async Task <CurrentCityWeatherDto> GetCurrentCityWeather(string city) { var response = await WeatherStackClient.GetCurrentCityWeather(city); if (response.CurrentWeather == null) { return(new CurrentCityWeatherDto()); } var currentTime = DateTime.Now.ToString("t"); var weatherDescription = response.CurrentWeather.WeatherDescriptions.FirstOrDefault(); var iconPath = GetIconPathCorrespondsToCode(response.CurrentWeather.WeatherCode); var dto = new CurrentCityWeatherDto() { City = response.Location.Name, Time = currentTime, WeatherDescription = weatherDescription, Temperature = response.CurrentWeather.Temperature, FeelsLike = response.CurrentWeather.FeelsLike, Humidity = response.CurrentWeather.Humidity, Pressure = response.CurrentWeather.Pressure, IconPath = iconPath }; return(dto); }
public IndexViewModel(CurrentCityWeatherDto dto) { City = dto.City; Time = dto.Time; IconPath = dto.IconPath; WeatherDescription = dto.WeatherDescription; Temperature = dto.Temperature; FeelsLike = dto.FeelsLike; Pressure = dto.Pressure; Humidity = dto.Humidity; }