public IActionResult Detail(string code) { DetailViewModel park = new DetailViewModel(); park.Park = _parkDAL.GetPark(code); park.Weather = _weatherDAL.GetWeather(code); park.ForecastRecommendation = _weatherDAL.CreateForecastRecommendation(park.Weather[0].Forecast); park.TemperatureRecommendation = _weatherDAL.CreateTemperatureRecommendation(park.Weather[0].LowTemp, park.Weather[0].HighTemp); if (HttpContext.Session.Get <string>("UnitOfTemp") == "celsius") { foreach (Weather weather in park.Weather) { weather.ConvertTemp(); } } return(View(park)); }
public void whenCreateForecastRecommendationRunsReturnsRainRecommendation() { using (var connection = new SqlConnection(NpGeekDbConnectionString)) { const string sql = @"INSERT park VALUES ('CVNP', 'Cuyahoga Valley National Park', 'Ohio', 32832, 696, 125, 0, 'Woodland', 2000, 2189849, 'Of all the paths you take in life, make sure a few of them are dirt.', 'John Muir', 'Though a short distance from the urban areas of Cleveland and Akron, Cuyahoga Valley National Park seems worlds away. The park is a refuge for native plants and wildlife, and provides routes of discovery for visitors. The winding Cuyahoga River gives way to deep forests, rolling hills, and open farmlands. Walk or ride the Towpath Trail to follow the historic route of the Ohio & Erie Canal', 0, 390); INSERT INTO weather VALUES('CVNP',1,38,62,'rain'); INSERT INTO weather VALUES('CVNP',2,38,56,'partly cloudy'); INSERT INTO weather VALUES('CVNP',3,51,66,'partly cloudy'); INSERT INTO weather VALUES('CVNP',4,55,65,'rain'); INSERT INTO weather VALUES('CVNP',5,53,69,'thunderstorms');"; var command = connection.CreateCommand(); command.CommandText = sql; connection.Open(); command.ExecuteNonQuery(); } IList <Weather> weather = _weatherDAL.GetWeather(parkCode); string recommendation = _weatherDAL.CreateForecastRecommendation(weather[0].Forecast); Assert.AreEqual("It's going to rain! Pack rain gear and wear waterproof shoes.", recommendation); }