public WeatherReport GetWeatherReport() { var weatherDataAccess = new ForecastIOWeatherDataAccess(); var weatherDataJSON = weatherDataAccess.GetWeatherJSON(Location.GetDefaultLocation()); JObject currentWeatherJSON = JObject.Parse(weatherDataJSON["currently"].ToString()); Weather currentWeather = WeatherDataMapper(currentWeatherJSON, "summary", "temperature"); JObject forecastWeatherJSON = JObject.Parse(weatherDataJSON["daily"].ToString()); List<Forecast> forecasts = ForecastsDataMapper(forecastWeatherJSON); WeatherReport LatestWeatherReport = new WeatherReport { CurrentWeather = currentWeather, FutureWeather = forecasts, Provider = "ForecastIO" }; return LatestWeatherReport; }
public WeatherReport GetWeatherReport() { var weatherDataAccess = new WundergroundWeatherDataAccess(); var weatherDataCurrentJSON = weatherDataAccess.GetWeatherCurrentJSON(Location.GetDefaultLocation()); var weatherDataCForecast10DayJSON = weatherDataAccess.GetWeatherForecast10DayJSON(Location.GetDefaultLocation()); JObject currentWeatherJSON = JObject.Parse(weatherDataCurrentJSON["current_observation"].ToString()); Weather currentWeather = WeatherDataMapper(currentWeatherJSON, "weather", "temp_f", ""); JObject forecastWeatherJSON = JObject.Parse(weatherDataCForecast10DayJSON["forecast"]["simpleforecast"].ToString()); List<Forecast> forecasts = ForecastsDataMapper(forecastWeatherJSON); WeatherReport LatestWeatherReport = new WeatherReport { CurrentWeather = currentWeather, FutureWeather = forecasts, Provider = "Wunderground" }; return LatestWeatherReport; }
public WeatherReport GetWeatherReportTest() { Weather currentWeather = new Weather { TemperatureFarenheit = 98.6, ConditionsDescription = "Hot and Sunny" }; Forecast forecast1 = new Forecast { ForecastDate = DateTime.Parse("11-01-2015"), ForecastDateDisplay = (DateTime.Parse("11-01-2015")).ToShortDateString(), ForecastWeather = new Weather { TemperatureFarenheit = 88.6, ConditionsDescription = "Warm and Rainy" } }; Forecast forecast2 = new Forecast { ForecastDate = DateTime.Parse("11-02-2015"), ForecastDateDisplay = (DateTime.Parse("11-02-2015")).ToShortDateString(), ForecastWeather = new Weather { TemperatureFarenheit = 78.6, ConditionsDescription = "Beautiful Day" } }; Forecast forecast3 = new Forecast { ForecastDate = DateTime.Parse("11-03-2015"), ForecastDateDisplay = (DateTime.Parse("11-03-2015")).ToShortDateString(), ForecastWeather = new Weather { TemperatureFarenheit = 68.6, ConditionsDescription = "Cool and Breezy" } }; List<Forecast> forecastList = new List<Forecast>(); forecastList.Add(forecast1); forecastList.Add(forecast2); forecastList.Add(forecast3); WeatherReport LatestWeatherReport = new WeatherReport { CurrentWeather = currentWeather, FutureWeather = forecastList }; return LatestWeatherReport; }