コード例 #1
0
        public new bool Equals(object obj1, object obj2)
        {
            QuestionBaseViewModel x = (QuestionBaseViewModel)obj1;
            QuestionBaseViewModel y = (QuestionBaseViewModel)obj2;

            return(x.Condition == y.Condition && x.Author.UserId == y.Author.UserId);
        }
コード例 #2
0
        public async Task <QuestionsListResponseViewModel> FetchQuestionListAsync(
            int index,
            int size = 20,
            Expression <Func <Question, bool> > predicate = null)
        {
            // TODO : This needs to changed to single query. For now this is fine.
            var questions = await this.questionsRepository
                            .GetListAsync(predicate : predicate,
                                          orderBy : order => order.OrderByDescending(x => x.Id),
                                          include : source => source.Include(x => x.QuestionTags)
                                          .ThenInclude(t => t.Question),
                                          index : index,
                                          size : size
                                          );

            var questionsList = new List <QuestionBaseViewModel>();

            foreach (var q in questions.Items)
            {
                QuestionBaseViewModel temp = await this.GetQuestionDetailResponseAsync(q, false);

                questionsList.Add(temp);
            }

            var result = new QuestionsListResponseViewModel();

            result.Items       = questionsList;
            result.Index       = questions.Index;
            result.Size        = questions.Size;
            result.Count       = questions.Count;
            result.Pages       = questions.Pages;
            result.HasPrevious = questions.HasPrevious;
            result.HasNext     = questions.HasNext;

            return(result);
        }