public ActionResult Survey() { SurveyDAL dal = new SurveyDAL(connectionString); //creates the dropdown list for parknames ViewBag.ParkNameDropdown = dal.ParkNameDropdown(); Survey s = new Survey(); //creates the dropdown list for statecodes ViewBag.StateCodeDropdown = s.Codes(); return(View("Survey", s)); }
public ActionResult Survey(Survey survey) { SurveyDAL dal = new SurveyDAL(connectionString); //get park code from the park name selected in dropdown list through method in DAO survey.ParkCode = dal.GetParkCodeForSurvey(survey.ParkName); ViewBag.ParkNameDropdown = dal.ParkNameDropdown(); ViewBag.StateCodeDropdown = survey.Codes(); survey.State = survey.GetStateName(survey.StateCode); //get state name from statecode method in model //if insert works then send to results page if (!ModelState.IsValid) { return(View("Survey", survey)); } dal.InsertSurvey(survey); return(RedirectToAction("SurveyResults")); }