Beispiel #1
0
        public async Task <IActionResult> ExamReview(int id)
        {
            var interview = await _interviewService.GetInterviewAsync(id);

            var exam = await _interviewService.GetExamAsync(interview.ExamId);

            var candidate = await _userService.GetCandidateAsync(interview.CandidateId);

            if (exam == null || candidate == null)
            {
                return(RedirectToAction(nameof(HomeController.Error)));
            }

            var answers       = new List <Answer>();
            var examQuestions = await _interviewService.GetQuestionsForExamAsync(interview.ExamId);

            if (examQuestions?.Any() == true)
            {
                foreach (var question in examQuestions)
                {
                    var questionAnswers = await _interviewService.GetAnswersForQuestionAsync(question.Id);

                    if (questionAnswers?.Any() == true)
                    {
                        answers.AddRange(questionAnswers);
                    }
                }
            }

            var responses = await _interviewService.GetResponsesForInterviewAsync(interview.Id);

            var viewModel = ViewModelBuilder.GetExamViewModel(interview, exam, candidate, examQuestions, answers);

            viewModel.Responses = ViewModelBuilder.GetResponseViewModels(responses);

            return(View(viewModel));
        }