/// <summary> /// Returns list of weather forecasts for use in GetDetails method /// </summary> /// <param name="parkCode"></param> /// <returns>list of weather forecasts</returns> public List <WeatherDayModel> GetFiveDayForecast(string parkCode) { List <WeatherDayModel> forecast = new List <WeatherDayModel>(); using (SqlConnection conn = new SqlConnection(_connectionString)) { conn.Open(); SqlCommand cmd = new SqlCommand(@"SELECT weather.* FROM weather " + "WHERE parkCode = @parkCode"); cmd.Parameters.AddWithValue("@parkCode", parkCode); cmd.Connection = conn; SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { WeatherDayModel day = new WeatherDayModel(); day.FiveDayForecastValue = (int)reader["fiveDayForecastValue"]; string forecastfield = (string)reader["forecast"]; if (forecastfield == "partly cloudy") { forecastfield = "partlyCloudy"; } day.Forecast = forecastfield; day.High = Convert.ToDouble(reader["high"]); day.Low = Convert.ToDouble(reader["low"]); day.ParkCode = parkCode; forecast.Add(day); } return(forecast); } }
public WeatherResult(WeatherDayModel m) : base( m.DayOfWeek + ": " + m.Condition.Text + " | " + m.MinTempC + "-" + m.MaxTempC + " C | " + m.MinTempF + "-" + m.MaxTempF + " F", "Rain " + m.ChanceOfRain + "% | Snow " + m.ChanceOfSnow + "% " + (m.PrecipitationMm > 0 ? "| Precipitation: " + m.PrecipitationMm + "mm/" + m.PrecipitationIn + "in " : "| ") + "| Max wind: " + m.WindMps + "m/s" ) { Icon = WeatherIconRepository.Get(m.Condition.IconUrl); foreach (var weatherHourModel in m.Hours) { Options.Add(new WeatherResult(weatherHourModel)); } }
public void Initialize() { weather = new WeatherDayModel(); }