namespace CMSMicroservice.Application.ProductTagCQ.Queries.GetProductTag;
public class GetProductTagQueryHandler : IRequestHandler<GetProductTagQuery, GetProductTagResponseDto>
{
    private readonly IApplicationDbContext _context;

    public GetProductTagQueryHandler(IApplicationDbContext context)
    {
        _context = context;
    }

    public async Task<GetProductTagResponseDto> Handle(GetProductTagQuery request,
        CancellationToken cancellationToken)
    {
        var response = await _context.ProductTags
            .AsNoTracking()
            .Where(x => x.Id == request.Id)
            .ProjectToType<GetProductTagResponseDto>()
            .FirstOrDefaultAsync(cancellationToken);

        return response ?? throw new NotFoundException(nameof(ProductTag), request.Id);
    }
}

