public async Task <GetArticleByIdResponse> Handle(GetArticleByIdRequest request)
 {
     return(new GetArticleByIdResponse()
     {
         Article = ArticleApiModel.FromArticle(await _context.Articles
                                               .Include(x => x.Author)
                                               .Include(x => x.Tenant)
                                               .SingleAsync(x => x.Id == request.Id && x.Tenant.UniqueId == request.TenantUniqueId))
     });
 }
Ejemplo n.º 2
0
 public async Task <GetPreviewArticleBySlugResponse> Handle(GetPreviewArticleBySlugRequest request)
 {
     return(new GetPreviewArticleBySlugResponse()
     {
         Article = ArticleApiModel.FromArticle(await _context.Articles
                                               .Include(x => x.Tenant)
                                               .Include(x => x.Tags)
                                               .Include(x => x.Author)
                                               .SingleAsync(a => a.Slug == request.Slug && a.Tenant.UniqueId == request.TenantUniqueId))
     });
 }
Ejemplo n.º 3
0
            public async Task <GetArticlesResponse> Handle(GetArticlesRequest request)
            {
                var articles = await _context.Articles
                               .Include(x => x.Author)
                               .Include(x => x.Tenant)
                               .ToListAsync();

                return(new GetArticlesResponse()
                {
                    Articles = articles
                               .Where(x =>
                                      x.Tenant != null &&
                                      x.Tenant.UniqueId == request.TenantUniqueId)
                               .Select(x => ArticleApiModel.FromArticle(x)).ToList()
                });
            }
            public async Task <GetLatestArticlesPageResponse> Handle(GetLatestArticlesPageRequest request)
            {
                var articles = await _context.Articles
                               .Include(x => x.Author)
                               .Include(x => x.Tenant)
                               .Include(x => x.Tags)
                               .Include(x => x.Categories)
                               .Where(x => x.Tenant != null && x.Tenant.UniqueId == request.TenantUniqueId && x.IsPublished)
                               .OrderByDescending(x => x.Published)
                               .Skip(request.Skip)
                               .Take(request.Take)
                               .ToListAsync();

                return(new GetLatestArticlesPageResponse()
                {
                    Articles = articles.Select(x => ArticleApiModel.FromArticle(x)).ToList()
                });
            }