public ActionResult DailySurvey(SurveyModel survey) { if (ModelState.IsValid) { surveyDAL.AddSurvey(survey); Session[Session_SurveyTaken] = true; return(RedirectToAction("DisplaySurveys", survey)); } else { List <SelectListItem> allParks = new List <SelectListItem>(); List <ParkModel> parks = parksDAL.GetParks(); foreach (ParkModel park in parks) { allParks.Add(new SelectListItem() { Text = park.ParkName, Value = park.ParkCode }); } ViewBag.ParkNames = allParks; ViewBag.States = GetStates(); ViewBag.Activity = ActivityLevel(); return(View("DailySurvey", survey)); } }
public ActionResult Index(Survey survey) { //Check to see if survey was successfully added to the DB bool surveyAdded = _surveyDAL.AddSurvey(survey.ParkCode, survey.Email, survey.State, survey.ActivityLevel); if (!surveyAdded) { return(View("Index")); } return(RedirectToAction("SurveyResults", "Survey")); }
public IActionResult SaveSurvey(Survey survey) { if (ModelState.IsValid) { surveyDAL.AddSurvey(survey); return(RedirectToAction("Favorites", "Survey")); } else { return(RedirectToAction("Index", "Survey")); } }
public IActionResult Index(Survey newSurvey) { if (ModelState.IsValid) { sdal.AddSurvey(newSurvey); TempData["Show_Message"] = true; return(RedirectToAction("surveyresults", "survey")); } var parkCodes = dal.GetParks(); var options = parkCodes.Select(parkCode => new SelectListItem() { Text = parkCode.ParkName, Value = parkCode.ParkCode }); ViewBag.ParkCode = options; return(View()); }
public ActionResult Submit(SurveyModel survey) { ActionResult result = null; if (!ModelState.IsValid) { result = Submit(); } else { bool success = _dal.AddSurvey(survey); if (!success) { result = Submit(); } else { result = RedirectToAction("Index"); } } return(result); }
public ActionResult PostList(Survey surveyModel) { surveyDAL.AddSurvey(surveyModel); return(RedirectToAction("Favorites")); }