Refactored IRepository<T> and ICatalogRepository to reside in the DbFirst.Application layer instead of Domain. Updated namespaces, using statements, and all references in services and handlers. Adjusted csproj dependencies to reflect the new structure. Updated comments to clarify Clean Architecture rationale and improved separation of concerns.
24 lines
741 B
C#
24 lines
741 B
C#
using AutoMapper;
|
|
using DbFirst.Application.Repositories;
|
|
using MediatR;
|
|
|
|
namespace DbFirst.Application.Catalogs.Queries;
|
|
|
|
public class GetCatalogByIdHandler : IRequestHandler<GetCatalogByIdQuery, CatalogReadDto?>
|
|
{
|
|
private readonly ICatalogRepository _repository;
|
|
private readonly IMapper _mapper;
|
|
|
|
public GetCatalogByIdHandler(ICatalogRepository repository, IMapper mapper)
|
|
{
|
|
_repository = repository;
|
|
_mapper = mapper;
|
|
}
|
|
|
|
public async Task<CatalogReadDto?> Handle(GetCatalogByIdQuery request, CancellationToken cancellationToken)
|
|
{
|
|
var item = await _repository.GetByIdAsync(request.Id, cancellationToken);
|
|
return item == null ? null : _mapper.Map<CatalogReadDto>(item);
|
|
}
|
|
}
|