mirror of
https://github.com/farcasclaudiu/PracticeCalendar.git
synced 2026-06-22 09:01:18 +03:00
play with storing valueobjects
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
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<List<ProductDto>>
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public class GetProductsQueryHandler : IRequestHandler<GetProductsQuery, List<ProductDto>>
|
||||
{
|
||||
private readonly ILogger<GetProductsQueryHandler> logger;
|
||||
private readonly IRepository<Product> eventsRepo;
|
||||
private readonly IMapper mapper;
|
||||
|
||||
public GetProductsQueryHandler(IRepository<Product> eventsRepo,
|
||||
ILogger<GetProductsQueryHandler> logger,
|
||||
IMapper mapper)
|
||||
{
|
||||
this.eventsRepo = eventsRepo;
|
||||
this.logger = logger;
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
public async Task<List<ProductDto>> Handle(GetProductsQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
var spec = new AllProductsSpecification();
|
||||
var evList = await eventsRepo.ListAsync(spec, cancellationToken);
|
||||
var lst = evList.Adapt<List<ProductDto>>(mapper.Config);
|
||||
return lst;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user