public async Task <GetAuthorByIdResponse> Handle(GetAuthorByIdRequest request) { return(new GetAuthorByIdResponse() { Author = AuthorApiModel.FromAuthor(await _dataContext.Authors.FindAsync(request.Id)) }); }
public async Task <GetAuthorsResponse> Handle(GetAuthorsRequest request) { var authors = await _dataContext.Authors.ToListAsync(); return(new GetAuthorsResponse() { 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.Title = article.Title; model.Slug = article.Slug; model.Teaser = article.Teaser; model.Body = article.Body; model.Author = AuthorApiModel.FromAuthor(article.Author); return(model); }