// To protect from overposting attacks, see https://aka.ms/RazorPagesCRUD public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } if (QuestionId != null) { await _databaseLogic.CreateAnswer(Answer, QuestionId); } else { await _databaseLogic.CreateAnswer(Answer); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } await _databaseLogic.CreateAnswer(Answer, Question.Id); NumberOfAnswersLeft -= 1; if (NumberOfAnswersLeft > 0) { return(RedirectToPage( new { numberOfAnswers = NumberOfAnswersLeft, numberOfQuestionsLeft = NumberOfQuestionsLeft, questionId = Question.Id })); } else if (NumberOfQuestionsLeft == null) { return(RedirectToPage( "/QuestionPages/Details", new { id = Question.Id })); } else if (NumberOfQuestionsLeft > 0) { return(RedirectToPage( "/QuestionPages/CreateMultipleQuestions", new { numberOfQuestionsLeft = NumberOfQuestionsLeft, surveyId = Survey.Id })); } return(RedirectToPage("/SurveyPages/CompleteSurvey", new { surveyId = Survey.Id })); }