/// <summary> /// The override of ExecuteSelection handles whatever selection was made by the user. /// This is where any business logic is executed. /// </summary> /// <param name="choice">"Key" of the user's menu selection</param> /// <returns></returns> protected override bool ExecuteSelection(string choice) { if (menuOptions.ContainsKey(choice)) { int intChoice = int.Parse(choice); Park park = ParkDAO.GetPark(intChoice); SubMenu1 subMenu1 = new SubMenu1(park, ParkDAO, CampgroundDAO, SiteDAO, ReservationDAO); subMenu1.Run(); return(true); } //switch (choice) //{ // case "1": // Do whatever option 1 is // int i1 = GetInteger("Enter the first integer: "); // int i2 = GetInteger("Enter the second integer: "); // Console.WriteLine($"{i1} + {i2} = {i1+i2}"); // Pause("Press enter to continue"); // return true; // Keep running the main menu // case "2": // Do whatever option 2 is // WriteError("Not yet implemented"); // Pause(""); // return true; // Keep running the main menu // case "3": // Create and show the sub-menu // SubMenu1 sm = new SubMenu1(); // sm.Run(); // return true; // Keep running the main menu //} return(true); }
public IActionResult ParkDescription(string id, string temppref) { if (id == null) { throw new ArgumentNullException(nameof(id)); } if (temppref == null) { temppref = HttpContext.Session.GetString("temppref"); if (temppref == null) { temppref = "f"; } } else { HttpContext.Session.SetString("temppref", temppref); } ViewData["temppref"] = temppref; Park park = parkDAO.GetPark(id); park.Weather = weatherDAO.GetWeather(park.ParkCode); return(View(park)); }
public IActionResult Detail(Park park) { string tempScale = HttpContext.Session.GetString("tempScale"); if (tempScale == null) { tempScale = "F"; HttpContext.Session.SetString("tempScale", tempScale); } park = parkDAO.GetPark(park.ParkCode); IList <Weather> weatherList = parkDAO.GetWeather(park.ParkCode); park.WeatherList = weatherList; park.TempScale = tempScale; Dictionary <string, string> weatherPrep = new Dictionary <string, string>() { { "sunny", "Pack sunblock" }, { "partly cloudy", "" }, { "cloudy", "" }, { "rain", "Pack Rain gear and wear waterproof shoes" }, { "thunderstorms", "Seek shelter and avoid hikin on exposed ridges" }, { "snow", "Pack snowshoes" } }; park.WeatherPrep = weatherPrep; return(View(park)); }
public IActionResult Detail(string code) { Park park = _db.GetPark(code); List <Weather> weathers = _db.GetWeather(park); ParkWeatherViewModel vm = new ParkWeatherViewModel(park, weathers); return(GetAuthenticatedView("Detail", vm)); }
public async Task <ActionResult> Detail(string parkCode) { Datum[] dataArray = null; var park = parkDAO.GetPark(parkCode); //accessing weather by database //var weather = weatherDAO.GetWeather(parkCode); //bool isFahrenheit = HttpContext.Session.Get<bool>("isF"); DetailViewModel detail = new DetailViewModel(park); string latitude = park.Latitude.ToString(); string longitude = park.Longitude.ToString(); using (var client = new HttpClient()) { client.BaseAddress = new Uri("https://api.darksky.net/forecast/11f6def22a0f23b0acdf9167bb8f7bf5/"); //HTTP GET var responseTask = client.GetAsync(latitude + "," + longitude + "?exclude=currently,minutely,hourly,alerts,flags"); responseTask.Wait(); var result = responseTask.Result; if (result.IsSuccessStatusCode) { string content = await result.Content.ReadAsStringAsync(); var weatherArray = JsonConvert.DeserializeObject <Rootobject>(content).daily.data; for (int i = 1; i < 6; i++) { Weather w = new Weather(); w.LowTemp = (int)weatherArray[i].temperatureLow; w.HighTemp = (int)weatherArray[i].temperatureHigh; w.ForecastString = weatherArray[i].icon; w.FiveDayForecastValue = i; w.ParkCode = parkCode; detail.Weathers.Add(w); } } } ViewData["dataArray"] = dataArray; if (HttpContext.Session.Keys.Contains("isF") == false) { HttpContext.Session.Set <bool>("isF", true); } foreach (Weather w in detail.Weathers) { w.isF = HttpContext.Session.Get <bool>("isF"); } bool isF = HttpContext.Session.Get <bool>("isF"); ViewData["isF"] = isF; return(View(detail)); }
public IActionResult GetPark(string parkCode) { ParkDetailVM vm = new ParkDetailVM(); vm.Park = parkDAO.GetPark(parkCode); vm.Weather = weatherDAO.GetWeather(parkCode); vm.Temperature = GetPreferredTemp(); return(View(vm)); }
/// <summary> /// Prints park info and options menu /// </summary> /// <param name="parkId"></param> private void PrintParkMenu(int parkId) { Console.WriteLine("Park Information Screen"); Console.WriteLine(parkDAO.GetPark(parkId).ToString()); Console.WriteLine("Select an option"); Console.WriteLine(" 1) View Campgrounds"); Console.WriteLine(" 2) Search for Reservations in All Campgrounds"); Console.WriteLine(" 3) Display All Reservations Whose Date Range Includes the Next 30 Days"); Console.WriteLine(" 4) Return to Previous Screen"); }
public void TestGetParkByCode() { Park park = _db.GetPark(TEST_PARK_CODE); Assert.AreEqual("Cuyahoga Valley National Park", park.ParkName, "The names do not match."); Assert.AreEqual("Ohio", park.State, "The states do not match."); Assert.AreEqual(32832, park.Acreage, "The acreage does not match."); Assert.AreEqual(696, park.Elevation, "The elevation does not match."); Assert.AreEqual(125, park.MilesOfTrail, "The trail length does not match."); Assert.AreEqual(0, park.NumberOfCampsites, "The campsites do not match."); Assert.AreEqual("Woodland", park.Climate, "The climates do not match."); Assert.AreEqual(2000, park.YearFounded, "The years do not match."); Assert.AreEqual(2189849, park.AnnualVisitorCount, "The visitor counts do not match."); Assert.AreEqual("John Muir", park.InspirationalQuoteSource, "The quote sources do not match."); Assert.AreEqual(0, park.EntryFee, "The entry fee does not match."); Assert.AreEqual(390, park.NumberOfAnimalSpecies, "The number of species do not match."); Assert.IsNotNull(park.Description, "Missing Description"); Assert.IsNotNull(park.InspirationalQuote, "Missing Quote"); }
public IActionResult GetPark(string parkCode) { //if user clicks on a park - calls GET and returns a lists park details ParkDetailVM vm = new ParkDetailVM(); vm.Park = parkDAO.GetPark(parkCode); vm.Weather = weatherDAO.GetWeather(parkCode); vm.Temperature = GetPreferredTemp(); return(View(vm)); }
public IActionResult Detail(string id) { Park parks = dao.GetPark(id); ViewBag.ForecastList = wdao.GetWeatherForecasts(id); if (HttpContext.Session.Keys.Contains("scale")) { ViewData["scale"] = HttpContext.Session.GetString("scale"); } else { ViewData["scale"] = "Fahrenheit"; } return(View(parks)); }
public IActionResult Detail(string parkCode) { //Get the selected park ParkDetailVM vm = new ParkDetailVM(); vm.Park = parkSqlDAO.GetPark(parkCode); //Get the user's preferred temperature units from session and store in view vm.TemperatureUnit = HttpContext.Session.GetString("TemperatureUnit"); //If not set yet, set to default of Fahrenheit if (String.IsNullOrEmpty(vm.TemperatureUnit)) { vm.TemperatureUnit = "F"; } //Get weather forecast for selected park from the National Weather Service API vm.FiveDayWeather = weatherAPIDAO.GetFiveDayWeatherForecast(vm.Park.LatLong); return(View(vm)); }
public IActionResult Detail(string parkCode) { Park park = ParkDAO.GetPark(parkCode); List <Forecast> forecasts = ParkDAO.GetFiveDayForecast(park); DetailVM vm = new DetailVM() { Park = park, Forecasts = forecasts, TempUnits = GetSessionTempUnits() }; foreach (Forecast forecast in vm.Forecasts) { forecast.TempUnits = vm.TempUnits; } // store the park and forecasts //string jsonVM = JsonConvert.SerializeObject(vm); //HttpContext.Session.SetString("detailVM", jsonVM); TempData["parkCode"] = vm.Park.ParkCode; return(View(vm)); }
public ActionResult Detail(string id) { Park park = parkDAO.GetPark(id); return(View(park)); }