public async void SetWeeklyRealTimeForeCast(string city, List <Day> week) { HttpClient client = new HttpClient(); string url = $"http://api.openweathermap.org/data/2.5/forecast?q={city}&APPID={API_KEY}&units=imperial"; HttpResponseMessage response = await client.GetAsync(url); string jsonResult = await response.Content.ReadAsStringAsync(); if (response.IsSuccessStatusCode) { Forecast.Forecast forecast = JsonConvert.DeserializeObject <Forecast.Forecast>(jsonResult); int threeHourIncrement = 0; for (int i = 0; i < week.Count - 1; i++) { if (i == 0) { week[i].weather.SetRealWeatherForcast(); week[i].SetRealCustomers(); } else { week[i].weather.SetWeatherForecast(forecast.list[threeHourIncrement].weather[0].description, (int)forecast.list[i].main.temp); week[i].SetRealCustomers(); week[i].weather.SetTodaysWeather(); threeHourIncrement += 8; } } } else { Console.WriteLine("Catastrophic Failure"); } }
public Outfit DressMe(Forecast.Forecast forecast) { Outfit outfit = new Outfit(); if (forecast.Condition == Forecast.Forecast.RAIN) { outfit.Accessories.Umbrella = true; } return(outfit); }