using AutoMapper; using DbFirst.Application.Repositories; using MediatR; namespace DbFirst.Application.Catalogs.Queries; public class GetCatalogByIdHandler : IRequestHandler { private readonly ICatalogRepository _repository; private readonly IMapper _mapper; public GetCatalogByIdHandler(ICatalogRepository repository, IMapper mapper) { _repository = repository; _mapper = mapper; } public async Task Handle(GetCatalogByIdQuery request, CancellationToken cancellationToken) { var item = await _repository.GetByIdAsync(request.Id, cancellationToken); return item == null ? null : _mapper.Map(item); } }