예제 #1
0
        public ActionResult FavoriteParks(SurveyModel model)
        {
            //Data validation to ensure user has entered an email address. Further validation occurs on View.
            if (model.Email == null)
            {
                TempData["errorStringEmail"] = "You must enter an email address";
                return(View("Survey", model));
            }

            /*This database call checks to see if the user has already submitted a survey for this park by
             * checking the provided email against the database. Error message is shown to user if they have already
             * posted a survey */
            bool doesSurveyExist = _dal.CheckForSurvey(model);

            if (doesSurveyExist == true)
            {
                TempData["errorString"] = "You cannot post more than one survey for this park";
                return(RedirectToAction("Survey"));
            }

            //Database method to add survey
            _dal.AddSurvey(model);

            return(RedirectToAction("FavoriteParks"));
        }
예제 #2
0
        public ActionResult SubmitForm(SurveyViewModel model)
        {
            ActionResult result;

            if (!ModelState.IsValid)
            {
                _surveryViewModel.ParkList = _dal.GetParks();
                result = View("Survey", _surveryViewModel);
            }
            else
            {
                _dal.AddSurvey(model.Survey);
                result = RedirectToAction("Index", "FavoriteParks");
            }
            return(result);
        }
예제 #3
0
        public ActionResult FavoriteParks(SurveyModel model)
        {
            if (model.Email == null)
            {
                TempData["errorStringEmail"] = "You must enter an email address";
                return(View("Survey", model));
            }

            bool doesSurveyExist = _dal.CheckForSurvey(model);

            if (doesSurveyExist == true)
            {
                TempData["errorString"] = "You cannot post more than one survey for this park";
                return(RedirectToAction("Survey"));
            }

            _dal.AddSurvey(model);

            return(RedirectToAction("FavoriteParks"));
        }