コード例 #1
0
 public async Task <IEnumerable <ArticleDto> > Handle(GetArticles request, CancellationToken cancellationToken)
 {
     return(_articles.Select(a => new ArticleDto
     {
         Title = a.Title,
         Description = a.Description,
         Id = a.Id,
         Body = a.Body,
         Tags = a.Tags,
     }));
 }
コード例 #2
0
        public async Task <IEnumerable <ArticleDto> > Handle(GetArticles request, CancellationToken cancellationToken)
        {
            var articles = await _context.Articles
                           .Include(a => a.Ads)
                           .Include(a => a.Comments)
                           .Include(a => a.Category)
                           .Include(a => a.Creator)
                           .Include(a => a.ContentVisitors)
                           .ToListAsync(cancellationToken);

            return(articles.AsDto());
        }
コード例 #3
0
 public async Task <PageModel <ArticleModel> > GetArticlesAsync([FromBody] GetArticles getArticles)
 {
     return(await _mediator.Send(getArticles));
 }