Update query to return IEnumerable<OutResDto>
Reordered using directives in DtoMappingProfile.cs. Added AutoMapper mapping for OutRes to OutResDto. Modified ReadOutResQuery to return IEnumerable<OutResDto>. Updated ReadOutResHandler to handle collection results: - Changed Handle method to return IEnumerable<OutResDto>. - Updated mapper.Map to map to a collection of OutResDto.
This commit is contained in:
parent
5cefe1457f
commit
5a226bfcea
@ -1,5 +1,4 @@
|
|||||||
using AutoMapper;
|
using ReC.Domain.Entities;
|
||||||
using ReC.Domain.Entities;
|
|
||||||
|
|
||||||
namespace ReC.Application.Common.Dto;
|
namespace ReC.Application.Common.Dto;
|
||||||
|
|
||||||
@ -8,5 +7,6 @@ public class DtoMappingProfile : AutoMapper.Profile
|
|||||||
public DtoMappingProfile()
|
public DtoMappingProfile()
|
||||||
{
|
{
|
||||||
CreateMap<RecActionView, RecActionDto>();
|
CreateMap<RecActionView, RecActionDto>();
|
||||||
|
CreateMap<OutRes, OutResDto>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,16 +8,16 @@ using ReC.Domain.Entities;
|
|||||||
|
|
||||||
namespace ReC.Application.OutResults.Queries;
|
namespace ReC.Application.OutResults.Queries;
|
||||||
|
|
||||||
public record ReadOutResQuery : IRequest<OutResDto>
|
public record ReadOutResQuery : IRequest<IEnumerable<OutResDto>>
|
||||||
{
|
{
|
||||||
public long? ProfileId { get; init; }
|
public long? ProfileId { get; init; }
|
||||||
|
|
||||||
public long? ActionId { get; init; }
|
public long? ActionId { get; init; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ReadOutResHandler(IRepository<OutRes> repo, IMapper mapper) : IRequestHandler<ReadOutResQuery, OutResDto>
|
public class ReadOutResHandler(IRepository<OutRes> repo, IMapper mapper) : IRequestHandler<ReadOutResQuery, IEnumerable<OutResDto>>
|
||||||
{
|
{
|
||||||
public async Task<OutResDto> Handle(ReadOutResQuery request, CancellationToken cancel)
|
public async Task<IEnumerable<OutResDto>> Handle(ReadOutResQuery request, CancellationToken cancel)
|
||||||
{
|
{
|
||||||
var q = repo.Query;
|
var q = repo.Query;
|
||||||
|
|
||||||
@ -32,6 +32,6 @@ public class ReadOutResHandler(IRepository<OutRes> repo, IMapper mapper) : IRequ
|
|||||||
if (resList.Count == 0)
|
if (resList.Count == 0)
|
||||||
throw new NotFoundException();
|
throw new NotFoundException();
|
||||||
|
|
||||||
return mapper.Map<OutResDto>(resList);
|
return mapper.Map<IEnumerable<OutResDto>>(resList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user