Beispiel #1
0
 public async Task <GetAuthorByIdResponse> Handle(GetAuthorByIdRequest request)
 {
     return(new GetAuthorByIdResponse()
     {
         Author = AuthorApiModel.FromAuthor(await _context.Authors.FindAsync(request.Id))
     });
 }
Beispiel #2
0
            public async Task <Response> Handle(GetAuthorsRequest request)
            {
                var authors = await _context.Authors.ToListAsync();

                return(new Response()
                {
                    Authors = authors.Select(x => AuthorApiModel.FromAuthor(x)).ToList()
                });
            }
Beispiel #3
0
        public static TModel FromArticle <TModel>(Article article) where
        TModel : ArticleApiModel, new()
        {
            var model = new TModel();

            model.Id          = article.Id;
            model.AuthorId    = article.AuthorId;
            model.Slug        = article.Slug;
            model.Title       = article.Title;
            model.HtmlContent = article.HtmlContent;
            model.Published   = article.Published;
            model.Author      = AuthorApiModel.FromAuthor(article.Author);
            model.Tags        = article.Tags.Select(t => TagApiModel.FromTag(t)).ToList();
            return(model);
        }