Пример #1
0
        public async Task <Answer> GetAcceptedAnswerByQuestionId(int questionId,
                                                                 CancellationToken cancellationToken)
        {
            var question = _questionGateway.GetQuestion(questionId).Result;
            var answers  = await _answersGateway.GetAllAnswers(cancellationToken);

            var questionAnswers = answers
                                  .Where(x => x.QuestionId == questionId)
                                  .FirstOrDefault(q => q.AnswerId == question.AcceptedAnswerId);

            return(questionAnswers);
        }
Пример #2
0
        public int GetAnswersCount(int questionId)
        {
            var count = _answersGateway.GetAllAnswers(new CancellationToken())
                        .Result.Count(x => x.QuestionId == questionId);

            return(count);
        }