private void GetForecast(XmlDocument doc) { string forecastListQuery = "weatherdata/forecast/*"; var forecasts = doc.SelectNodes(forecastListQuery); foreach (XmlNode forecastNode in forecasts) { var forecast = new Forecast(forecastNode); Forecasts.Add(forecast); } }
public static List <ForecastView> GetForecastList(Example forecasts) { List <ForecastView> newForecastViews = new List <ForecastView>(); for (int i = 0; i < 7; i++) { Forecast forecast = forecasts.Query.Results.Channel[i].Item.Forecast; Wind wind = forecasts.Query.Results.Channel[i].Wind; newForecastViews.Add(new ForecastView { Date = forecast.Date, Temperature = forecast.High + " °C", WindSpeed = GetFormatedWindSpeed(wind.Speed), WeatherImage = GetImage(forecast.Text), }); } return(newForecastViews); }
private Weather GetWeatherFromApi(string city) { var weather = new Weather(); var client = new WebClient(); string url = "https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20woeid%20in%20(select%20woeid%20from%20geo.places(1)%20where%20text%3D%22" + city + "%22)%20and%20u%20=%20%27c%27%20&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys"; var obj = JsonConvert.DeserializeObject <dynamic>(client.DownloadString(url)); weather.City = obj.query.results.channel.location.city; weather.TemperatureCurrent = obj.query.results.channel.item.condition.temp; weather.Code = obj.query.results.channel.item.forecast[0].code; weather.Date = DateTime.Parse(obj.query.created.ToString("dd-MM-yyyy HH:mm:ss")); foreach (var item in obj.query.results.channel.item.forecast) { var temp = new Forecast(); temp.TemperatureDay = item.high; temp.TemperatureNight = item.low; temp.Code = item.code; weather.Forecast.Add(temp); } return(weather); }
public HourModel(Forecast f) { data = f; }
public HourVM(Forecast hour) { model = new HourModel(hour); Hour = hour; }
public string ToQuery(Forecast f) { return($"({f.Id}, '{Value}', {FixDouble.ToString(All)}),"); }
public string ToQuery(Forecast f) { return($"({f.Id}, {FixDouble.ToString(Number)}, '{Name}','{Var}'),"); }
public string ToQuery(Forecast f) { return($"({f.Id}, '{Unit}', {FixDouble.ToString(Value)}, '{Type}'),"); }
public string ToQuery(Forecast f) { return($"({f.Id}, '{UnitType}', {FixDouble.ToString(Value)}, " + $"{FixDouble.ToString(Min)}, {FixDouble.ToString(Max)}),"); }
public string ToSpeedQuery(Forecast f) { return($"({f.Id}, {FixDouble.ToString(Speed)}, '{SpeedName}'),"); }
public string ToDirQuery(Forecast f) { return($"({f.Id}, {FixDouble.ToString(Direction)}, '{Code}','{DirectionName}'),"); }
public ForecastPage() { InitializeComponent(); BindingContext = new Forecast(); }
public DailyVM(Forecast daily) { model = new HourModel(daily); Daily = daily; }