Exemple #1
0
 public WeatherForecast(OWMForeCast owm)
 {
     if (owm.List == null)
     {
         throw new ArgumentException(owm.ToString());
     }
     this.CityName = owm.City?.Name;
     this.Days     = owm.List
                     .GroupBy(DateSelector)
                     .Select(grp => new WeatherForecastDay(grp.Key, grp.ToArray()))
                     .ToArray();
 }
Exemple #2
0
        public async Task <WeatherForecast> GetForecastAsync()
        {
            try
            {
                OWMForeCast fc = await this.GetOpenWeatherMapForecastAsync();

                var result = new WeatherForecast(fc);
                this._cachedResult = result;
                return(result);
            }
            catch (Exception e)
            {
                this._logger.LogError(e, "Failed to query OpenWeatherMap forecast");
                return(this._cachedResult); // might be null or outdated but our best guess.
            }
        }