public ActionResult TakeSurvey() { List <ParkModel> parks = parkDAL.GetAllParks(); SurveyFormModel emptySurvey = new SurveyFormModel(); emptySurvey.AvailableParks = parks; return(View("TakeSurvey", emptySurvey)); }
public ActionResult TakeSurvey(SurveyFormModel survey) { if (!ModelState.IsValid) { List <ParkModel> parks = parkDAL.GetAllParks(); survey.AvailableParks = parks; return(View("TakeSurvey", survey)); } surveyDAL.SaveSurveyForm(survey); return(RedirectToAction("Results")); }
public IActionResult Edit(SurveyFormModel model) { var filePath = string.Format(GetSurveysJsonPath(), Directory.GetCurrentDirectory()); if (!ObjToJsonConverterExtensions.EditSurveyInJsonFile(filePath, model)) { this.TempData.AddWarningMessage(string.Format(TempDataEditFailText, ModelName, EndingLetterO)); return(this.RedirectToAction(nameof(this.Edit))); } this.TempData.AddSuccessMessage(string.Format(TempDataEditCommentText, ModelName, EndingLetterO)); return(this.RedirectToAction("Articles", nameof(ArticlesController.Articles))); }
public bool SaveSurveyForm(SurveyFormModel surveyForm) { try { using (SqlConnection conn = new SqlConnection(connectionString)) { conn.Open(); SqlCommand cmd = new SqlCommand(SQL_SaveSurveyForm, conn); cmd.Parameters.AddWithValue("parkCode", surveyForm.ParkCode); cmd.Parameters.AddWithValue("emailAddress", surveyForm.Email); cmd.Parameters.AddWithValue("state", surveyForm.State); cmd.Parameters.AddWithValue("activityLevel", surveyForm.ActivityLevel); int numRowsAffected = cmd.ExecuteNonQuery(); return(numRowsAffected > 0); } } catch (SqlException) { throw; } }