public async Task <GetAuthorByIdResponse> Handle(GetAuthorByIdRequest request) { return(new GetAuthorByIdResponse() { Author = AuthorApiModel.FromAuthor(await _context.Authors.FindAsync(request.Id)) }); }
public async Task <Response> Handle(GetAuthorsRequest request) { var authors = await _context.Authors.ToListAsync(); return(new Response() { Authors = authors.Select(x => AuthorApiModel.FromAuthor(x)).ToList() }); }
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); }