public void UpdateWeather() { var currentWeather = this.WeatherMapClient.CurrentWeather. GetByName(this.CityName, MetricSystem.Metric, OpenWeatherMapLanguage.RU).GetAwaiter().GetResult(); WeatherNote note = new WeatherNote() { Temperature = (int)currentWeather.Temperature.Value, WindSpeed = (int)currentWeather.Wind.Speed.Value, Moment = DateTime.Now }; this.NoteToDB(note); }
public async Task UpdateWeatherAsync() { var currentWeather = await this.WeatherMapClient.CurrentWeather. GetByName(this.CityName, MetricSystem.Metric, OpenWeatherMapLanguage.RU); WeatherNote note = new WeatherNote() { Temperature = (int)currentWeather.Temperature.Value, WindSpeed = (int)currentWeather.Wind.Speed.Value, Moment = DateTime.Now }; this.NoteToDB(note); }
private void NoteToDB(WeatherNote weatherNote) { this.NotesContext.WeatherNotes.Add(weatherNote); this.NotesContext.SaveChanges(); }