/// <summary> /// Execute Http request to fetch weather data asynchronously /// </summary> /// <param name="cityName"></param> public async void GetWeather(string cityName) { var data = await service.GetForecastAsync(cityName); today = data.First(); var localTime = DateTime.Now.Add(TimeSpan.FromSeconds(today.UTCOffsetInSecs)); // Tomorrow tomorrow = new WeatherForecast(); forecastData = data.Where(i => i.Date.Day == localTime.Date.AddDays(1).Day).ToList(); Tuple <int, int> tuple = ProcessData(forecastData, out tomorrow); tomorrow.MinTemperature = tuple.Item1; tomorrow.MaxTemperature = tuple.Item2; forecastData.Clear(); // AfterTomorrow afterTomorrow = new WeatherForecast(); forecastData = data.Where(i => i.Date.Day == localTime.Date.AddDays(2).Day).ToList(); tuple = ProcessData(forecastData, out afterTomorrow); afterTomorrow.MinTemperature = tuple.Item1; afterTomorrow.MaxTemperature = tuple.Item2; forecastData.Clear(); // AfterTomorrow + 1 Day forecastData = data.Where(i => i.Date.Day == localTime.Date.AddDays(3).Day).ToList(); fourth = new WeatherForecast(); tuple = ProcessData(forecastData, out fourth); fourth.MinTemperature = tuple.Item1; fourth.MaxTemperature = tuple.Item2; // AfterTomorrow + 2 Days forecastData = data.Where(i => i.Date.Day == localTime.Date.AddDays(4).Day).ToList(); fifth = new WeatherForecast(); tuple = ProcessData(forecastData, out fifth); fifth.MinTemperature = tuple.Item1; fifth.MaxTemperature = tuple.Item2; UpdateUIElements(); }