Beispiel #1
0
        public async Task <List <QuestionDTO <FilledInAnswerDTO> > > Handle(FilledInAnswersQuery message, CancellationToken cancellationToken)
        {
            List <Entities.Answer> answers = null;

            if (message.FormId > 0)
            {
                answers = await _context.Answers
                          .Include(r => r.OptionAnswered)
                          .ThenInclude(rd => rd.Question)
                          .ThenInclude(q => q.FormSection)
                          .Include(r => r.OptionAnswered)
                          .ThenInclude(rd => rd.Option)
                          .Where(r => r.UserId == message.UserId && r.BeneficiaryId == message.BeneficiaryId && r.OptionAnswered.Question.FormSection.FormId == message.FormId)
                          .ToListAsync(cancellationToken: cancellationToken);
            }
            else
            {
                answers = await _context.Answers
                          .Include(r => r.OptionAnswered)
                          .ThenInclude(rd => rd.Question)
                          .ThenInclude(q => q.FormSection)
                          .Include(r => r.OptionAnswered)
                          .ThenInclude(rd => rd.Option)
                          .Where(r => r.UserId == message.UserId && r.BeneficiaryId == message.BeneficiaryId)
                          .ToListAsync(cancellationToken: cancellationToken);
            }

            var intrebari = answers
                            .Select(r => r.OptionAnswered.Question)
                            .ToList();

            return(intrebari.Select(i => _mapper.Map <QuestionDTO <FilledInAnswerDTO> >(i)).ToList());
        }
        public async Task <List <QuestionDTO <FilledInAnswerDTO> > > Handle(FilledInAnswersQuery message, CancellationToken cancellationToken)
        {
            var raspunsuri = await _context.Answers
                             .Include(r => r.OptionAnswered)
                             .ThenInclude(rd => rd.Question)
                             .Include(r => r.OptionAnswered)
                             .ThenInclude(rd => rd.Option)
                             .Where(r => r.IdObserver == message.ObserverId && r.IdPollingStation == message.PollingStationId)
                             .ToListAsync(cancellationToken: cancellationToken);

            var intrebari = raspunsuri
                            .Select(r => r.OptionAnswered.Question)
                            .ToList();

            return(intrebari.Select(i => _mapper.Map <QuestionDTO <FilledInAnswerDTO> >(i)).ToList());
        }