public async Task <IActionResult> AnswerTheQuestion(QuestionnaireViewModel questionnaireVm) { if (!ModelState.IsValid || string.IsNullOrEmpty(questionnaireVm.AnswerContent)) { ModelState.AddModelError("", "Поля заполнены не полностью или не верно."); return(View(questionnaireVm)); } _questionnaireRepo.AddAnswer(new Answer { AnswerContent = questionnaireVm.AnswerContent, QuestionId = questionnaireVm.QuestionId, RespondentId = questionnaireVm.RespondentId }); if (await _questionnaireRepo.IsLastQuestion(questionnaireVm.QuestionId)) { return(RedirectToAction("FinishQuestionnaire")); } var nextQuestionOrder = questionnaireVm.QuestionId + 1; return(RedirectToAction("AnswerTheQuestion", "Home", new { respondentId = questionnaireVm.RespondentId, questionId = nextQuestionOrder })); }