コード例 #1
0
        public Task <TopicIndexModel> Handle(GetAllTopicsQuery request, CancellationToken cancellationToken)
        {
            var topics         = _topicsRepository.GetYoungestTwenty().ToList();
            var getTopicModels = topics.Select(t => new GetTopicModel
            {
                Id         = t.Id,
                Title      = t.Title,
                CreatedBy  = _userManager.FindByIdAsync(t.CreatedBy).Result.UserName,
                VotesCount = _votesRepository.GetCountOfVotesForTopic(t.Id)
            });

            var topicIndexModel = new TopicIndexModel
            {
                GetTopicModels = getTopicModels
            };

            return(Task.FromResult(topicIndexModel));
        }