public WeatherModels GetYahooWeather(string zipCode) { WeatherModels model = new WeatherModels(); string weatherUrl = string.Format(yahooWeatherUrl, zipCode); return(model); }
public void GivenIHaveLaunchedTheWeatherApp() { _weatherPageModel = WeatherModels.NavigateToWeatherPage(); }
private async void GetWeather(DateTime dateFrom, DateTime dateTo) { IRepository repo = new Repository(); var dateNow = DateTime.Today; int fromForecastDays = -1; int toForecastDays = -1; if (dateFrom.Date <= dateNow.AddDays(7).Date&& dateFrom.Date >= dateNow.Date) { var timeSpan = dateFrom.Date - dateNow.Date; fromForecastDays = timeSpan.Days; } if (dateTo.Date <= dateNow.AddDays(7).Date&& dateTo.Date >= dateNow.Date) { var timeSpan = dateTo.Date - dateNow.Date; toForecastDays = timeSpan.Days; } var localWeatherResult = new WeatherModel(); try { localWeatherResult = repo.GetWeatherDataByAutoIP(key, Days.Seven); //var cityWeatherResult = repo.GetWeatherData(key, GetBy.CityName, "goeteborg", Days.One); } catch (Exception) { await MessageDialogService.ShowInfoDialog($"The Weather data could not be loaded."); return; } WeatherDisplayModel weatherDisplayModelFromDate; if (fromForecastDays >= 0 && fromForecastDays <= 7) { weatherDisplayModelFromDate = new WeatherDisplayModel() { Icon = "http:" + localWeatherResult.forecast.forecastday[fromForecastDays].day.condition.icon, Text = $"Date: {localWeatherResult.forecast.forecastday[fromForecastDays].date} " + $"Temp: Min {localWeatherResult.forecast.forecastday[fromForecastDays].day.mintemp_c}°C, " + $"Max {localWeatherResult.forecast.forecastday[fromForecastDays].day.maxtemp_c}°C" }; } else { weatherDisplayModelFromDate = new WeatherDisplayModel() { Icon = "", Text = $"No weather data can be found at this date..." }; } WeatherDisplayModel weatherDisplayModelToDate; if (toForecastDays >= 0 && toForecastDays <= 7) { weatherDisplayModelToDate = new WeatherDisplayModel() { Icon = "http:" + localWeatherResult.forecast.forecastday[toForecastDays].day.condition.icon, Text = $"Date: {localWeatherResult.forecast.forecastday[toForecastDays].date} " + $"Temp: Min {localWeatherResult.forecast.forecastday[toForecastDays].day.mintemp_c}°C, " + $"Max {localWeatherResult.forecast.forecastday[toForecastDays].day.maxtemp_c}°C" }; } else { weatherDisplayModelToDate = new WeatherDisplayModel() { Icon = "", Text = $"No weather data can be found at this date..." }; } WeatherModels.Clear(); WeatherModels.Add(weatherDisplayModelFromDate); WeatherModels.Add(weatherDisplayModelToDate); }