Esempio n. 1
0
 public async Task <GetArticleBySlugResponse> Handle(GetArticleBySlugRequest request)
 {
     return(new GetArticleBySlugResponse()
     {
         Article = ArticleApiModel.FromArticle(await _context.Articles.SingleAsync(a => a.Slug == request.Slug))
     });
 }
Esempio n. 2
0
 public async Task <GetArticleByIdResponse> Handle(GetArticleByIdRequest request)
 {
     return(new GetArticleByIdResponse()
     {
         Article = ArticleApiModel.FromArticle(await _context.Articles
                                               .Include(x => x.Author)
                                               .SingleAsync(x => x.Id == request.Id))
     });
 }
Esempio n. 3
0
 public async Task <Response> Handle(Request request)
 {
     return(new Response()
     {
         Article = ArticleApiModel.FromArticle(await _context.Articles
                                               .Include(x => x.Tenant)
                                               .Where(x => x.Tenant.UniqueId == request.TenantUniqueId)
                                               .SingleAsync(a => a.Slug == request.Slug))
     });
 }
Esempio n. 4
0
            public async Task <GetArticlesResponse> Handle(GetArticlesRequest request)
            {
                var articles = await _context.Articles
                               .Include(x => x.Author)
                               .ToListAsync();

                return(new GetArticlesResponse()
                {
                    Articles = articles.Select(x => ArticleApiModel.FromArticle(x)).ToList()
                });
            }
Esempio n. 5
0
            public async Task <Response> Handle(Request request)
            {
                var articles = await _context.Articles
                               .Include(x => x.Author)
                               .Include(x => x.Tenant)
                               .Where(x => x.Tenant.UniqueId == request.TenantUniqueId)
                               .ToListAsync();

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