public async Task <Forecast> GetForecast(Park park) { string query = $"{_apiKey}/{park.Latitude},{park.Longitude}?exclude=currently,minutely,hourly,alerts,flags"; HttpResponseMessage response = await httpClient.GetAsync($"{baseUri}{query}"); response.EnsureSuccessStatusCode(); responseBody = await response.Content.ReadAsStringAsync(); // Forecast - "daily" data block with 8 data points for 8 days of weather Forecast forecast = JsonConvert.DeserializeObject <Forecast>(responseBody); return(forecast); }
public List <Weather> GetWeatherForWeek(Park park, Forecast forecast) { List <Weather> WeekOfWeather = new List <Weather>(); // Creates Weather objects for each day foreach (DataPoint day in forecast.Daily.Data) { Weather w = new Weather { ParkCode = park.ParkCode, ForecastDate = UnixTimeStampToDateTime(day.TimeUnix), LowTemp = day.TemperatureLow, HighTemp = day.TemperatureHigh, Forecast = day.Icon }; WeekOfWeather.Add(w); } return(WeekOfWeather); }