예제 #1
0
        public async Task <IActionResult> OnGetAsync()
        {
            CourseClass = await CourseClasses.FindAsync(Id);

            if (CourseClass == null)
            {
                return(NotFound());
            }

            var type = (SurveyQuestion.SurveyQuestionTypes)Type;

            switch (type)
            {
            case SurveyQuestion.SurveyQuestionTypes.Qualitative:
                Question = new SurveyQuestionQualitative();
                break;

            case SurveyQuestion.SurveyQuestionTypes.Rate:
                Question = new SurveyQuestionRate();
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            return(Page());
        }
 private void ValidateQuestion(SurveyAnswerQualitative answer, SurveyQuestionQualitative question, int i)
 {
     if (question.Required)
     {
         if (string.IsNullOrEmpty(answer.Response))
         {
             ModelState.AddModelError($"SurveyResponses[{i}].Answer.Response", "Answer is required.");
         }
     }
 }