public IActionResult Detail(string id, ParkDetails currentDetails) { //compares the current user choice agains the user choice saved in the session, updating it if necessary bool currentTempCondition = CompareTemperatureDetails(currentDetails.IsCelsius); //assigns the value from the session to the model. currentDetails.IsCelsius = currentTempCondition; //uses the id from the park page that the user selected to get info on the specific park, putting it into a list with only one index. IList <Park> SingleParkList = parkDAO.GetSelectedPark(id); Park SelectedPark = new Park(); //gets the park out of the list and assigns it to a single park. SelectedPark = SingleParkList[0]; //takes the single park and assigns it to the parkdetails object to be passed to the detail page currentDetails.DetailPark = SelectedPark; //get two lists of weather details; a fahrenheit one for making comparisons for giving weather advice, and a second for displaying user temp preference. currentDetails.FahrenheitWeather = weatherDAO.GetWeather(id); currentDetails.AllWeather = weatherDAO.GetWeather(id); //if the condition of the session/model is false, run the temperatures in the list through a converter if (currentTempCondition == true) { currentDetails.AllWeather = currentDetails.ConvertTemp(currentDetails.AllWeather, currentTempCondition); } return(View(currentDetails)); }
// GET: Park/Details public ActionResult Details(string id) { ParkDetails model = new ParkDetails(); model.Weather = dal2.GetForcast(id); model.Park = dal.GetParkDetails(id); if (Session["TempUnit"] == null) { foreach (Weather weather in model.Weather) { weather.Unit = 'F'; weather.Farhrenheit = true; Session["TempUnit"] = weather.Unit; } } else if ((char)Session["TempUnit"] == 'C') { Session["TempUnit"] = 'F'; foreach (Weather weather in model.Weather) { weather.Unit = 'F'; weather.TempConversion('F'); weather.Celcius = true; Session["TempUnit"] = weather.Unit; } } else { Session["TempUnit"] = 'C'; } return(View("Details", model)); }
//if (Session["TempUnit"] == null) //{ // Session["TempUnit"] = 'F'; //} //else if ((bool)Session["ShouldUnitChange"]) //{ // if ((char)Session["TempUnit"] == 'F') // { // foreach (Weather weather in model.Weather) // { // weather.TempConversion((char)Session["TempUnit"]); // } // Session["TempUnit"] = 'C'; // } // else if ((char)Session["TempUnit"] == 'C') // { // Session["TempUnit"] = 'F'; // } // Session["ShouldUnitChange"] = false; //} //else if ((char)Session["TempUnit"] == 'C') //{ // foreach (Weather weather in model.Weather) // { // weather.TempConversion('F'); // } // if ((bool)Session["ShouldUnitChange"]) // { // foreach (Weather weather in model.Weather) // { // weather.TempConversion((char)Session["TempUnit"]); // } // Session["TempUnit"] = 'F'; // } //} //address case for where the Session is already in Cel 'C' //model.Park = dal.GetParkDetails(id); //Session["TempUnit"] = model; //return View("Details", Session["TempUnit"]); public ActionResult ChangeTemperatureUnit(string parkCode) { ParkDetails model = new ParkDetails(); model.Park = dal.GetParkDetails(parkCode); model.Weather = dal2.GetForcast(parkCode); foreach (Weather weather in model.Weather) { if (Session["TempUnit"] == null) { weather.Farhrenheit = true; weather.Celcius = false; weather.Unit = 'F'; } else if ((char)Session["TempUnit"] == 'F') { weather.Farhrenheit = false; weather.Celcius = true; weather.Unit = 'C'; } else { weather.Celcius = false; weather.Farhrenheit = true; weather.Unit = 'F'; } } return(RedirectToAction("Details", new { id = parkCode })); }
public void GetAllDetailsByParkCode() { //Arrange NPGeekDAL _dal = new NPGeekDAL(_connectionString); //Act ParkDetails parkDetailsItem = _dal.GetAllDetailsByParkCode("CVNP"); //Assert Assert.AreEqual("Cuyahoga Valley National Park", parkDetailsItem.ParkName); }
public async Task <IActionResult> PostParkDetails([FromBody] ParkDetails parkDetails) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.ParkDet.Add(parkDetails); await _context.SaveChangesAsync(); return(CreatedAtAction("GetParkDetails", new { id = parkDetails.Id }, parkDetails)); }
public void PutParkDetails([FromBody] ParkDetails parkDetails) { var json = Newtonsoft.Json.JsonConvert.SerializeObject(new { Name = parkDetails.Id, Value = parkDetails.Status, }); var request = WebRequest.CreateHttp("https://parkingdb-a7779.firebaseio.com/Parcare1/.json"); request.Method = "PATCH"; request.ContentType = "application/json"; var buffer = Encoding.UTF8.GetBytes(json); request.ContentLength = buffer.Length; request.GetRequestStream().Write(buffer, 0, buffer.Length); var response = request.GetResponse(); json = (new StreamReader(response.GetResponseStream())).ReadToEnd(); }
public IActionResult Detail(string id) { ParkDetails currentDetails = new ParkDetails(); currentDetails.IsCelsius = AccessTemperatureDetails(); //uses the id from the park page that the user selected to get info on the specific park, putting it into a list with only one index. IList <Park> SingleParkList = parkDAO.GetSelectedPark(id); Park SelectedPark = new Park(); //gets the park out of the list and assigns it to a single park. SelectedPark = SingleParkList[0]; //takes the single park and assigns it to the parkdetails object to be passed to the detail page currentDetails.DetailPark = SelectedPark; currentDetails.FahrenheitWeather = weatherDAO.GetWeather(id); currentDetails.AllWeather = weatherDAO.GetWeather(id); if (currentDetails.IsCelsius == true) { currentDetails.AllWeather = currentDetails.ConvertTemp(currentDetails.AllWeather, currentDetails.IsCelsius); } return(View(currentDetails)); }
public ParkDetails GetAllDetailsByParkCode(string parkCode) { ParkDetails parkDetails = new ParkDetails(); string query = @"SELECT * FROM park WHERE parkCode = @parkCode"; using (SqlConnection conn = new SqlConnection(connectionString)) { conn.Open(); SqlCommand cmd = new SqlCommand(query, conn); cmd.Parameters.AddWithValue("@parkCode", parkCode); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { parkDetails = MapRowToParkDetails(reader); } } return(parkDetails); }