Пример #1
0
        public async Task <GetListOfQuestionsQueryResponse> Handle(GetListOfQuestionsQuery request, CancellationToken cancellationToken)
        {
            var questions = await _dbContext.FindQuestionsForQuiz(request.QuizId, cancellationToken);

            return(new GetListOfQuestionsQueryResponse()
            {
                Questions = (from question in questions.AsParallel().AsOrdered()
                             select new QuestionViewModel()
                {
                    Id = question.Id,
                    Text = question.Text,
                    Choices =
                        from choice in question.Choices
                        select new ChoiceViewModel()
                    {
                        Id = choice.Id,
                        Text = choice.Text,
                        IsCorrect = choice.IsCorrect
                    }
                }).ToList()
            });
        }