예제 #1
0
        public ViewResult RsvpForm(CompetitionInvite invite)
        {
            //string to hold value of html element that has the name attribute success
            string request = Request.Form["success"];

            //if the request is true
            if (request == "true")
            {
                //set WillAttend as true
                invite.WillAttend = true;
            }
            //if request is not true
            else
            {
                //set WillAttend as false
                invite.WillAttend = false;
            }
            //Check if form is valid
            if (ModelState.IsValid)
            {
                //Add response to Repository list
                Repository.AddResponse(invite);
                //returns user to Thanks.cshtml with parameter invite to extract data in view
                return(View("Thanks", invite));
            }
            //If data is not valid
            else
            {
                //Redirect user back to RsvpForm
                return(View());
            }
        }
예제 #2
0
 public ViewResult RsvpForm(CompetitionInvite competitionInvite)
 {
     if (ModelState.IsValid)
     {
         Repository.AddResponse(competitionInvite);
         return(View("Thanks", competitionInvite));
     }
     else
     {
         // there is a validation error
         return(View());
     }
 }