namespace Yes.Application.Admins.Articles { public record GetArticleQuery(int Id) : IRequest; public record GetArticleQueryResponse( int Id, string Title, int CategoryId, string Content, string Slug, string CoverUrl, string? Summary, string[] Tags ); public class GetArticleQueryHandler(BlogDbContext db,IMapper mapper) : IRequestHandler { private readonly BlogDbContext _db = db; private readonly IMapper _mapper = mapper; public async Task Handle(GetArticleQuery request, CancellationToken cancellationToken) { var article = await _db.Articles.FindAsync(request.Id); if (article == null|| article.Status== ArticleStatusEnum.Deleted) { throw new ArticleNotExistsException(request.Id); } var response = _mapper.Map(article); return response; } } internal class GetArticleMappingProfile : IRegister { public void Register(TypeAdapterConfig config) { config.ForType() .Map(dest => dest.Tags, src => src.Tag.ToTags()); ; } } }