コード例 #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 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"));
        }