Ejemplo n.º 1
0
        // Getting the Name of the Zip code area
        public async Task <WeatherLocation> GetDescription(string zip)
        {
            try
            {
                WeatherLocation weather = this.DbService.ZipSearch(zip);
                Console.WriteLine(weather);
                if (weather == null)
                {
                    weather = await WeatherHelper.GetWeatherDescription(zip);

                    this.DbService.AddLocation(weather);
                }
                // TODO:: FIX THIS FOR REALS
                else if (weather.Forecasts[0].Date != DateTime.Today.ToString("MM/dd h:mm tt"))
                {
                    weather = await WeatherHelper.GetWeatherDescription(zip);

                    await this.DbService.ReplaceWeatherDocument(weather.Zip, weather);
                }
                return(weather);
            }
            catch (HttpRequestException httpRequestException)
            {
                return(null); // ($"Error getting weather from OpenWeather: {httpRequestException.Message}");
            }
        }