using Mapster; using MapsterMapper; using MediatR; using Microsoft.Extensions.Logging; using PracticeCalendar.Domain.Common.Interfaces; using PracticeCalendar.Domain.Entities.Product; using PracticeCalendar.Domain.Entities.Product.Specifications; namespace PracticeCalendar.Application.Products.Queries.GetProducts { public class GetProductsQuery : IRequest> { } public class GetProductsQueryHandler : IRequestHandler> { private readonly ILogger logger; private readonly IRepository eventsRepo; private readonly IMapper mapper; public GetProductsQueryHandler(IRepository eventsRepo, ILogger logger, IMapper mapper) { this.eventsRepo = eventsRepo; this.logger = logger; this.mapper = mapper; } public async Task> Handle(GetProductsQuery request, CancellationToken cancellationToken) { var spec = new AllProductsSpecification(); var evList = await eventsRepo.ListAsync(spec, cancellationToken); var lst = evList.Adapt>(mapper.Config); return lst; } } }