init ReadRecAction query
This commit is contained in:
parent
d8d75829f0
commit
20ca2c2e48
@ -8,7 +8,11 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="AutoMapper" Version="15.1.0" />
|
<PackageReference Include="AutoMapper" Version="15.1.0" />
|
||||||
|
<PackageReference Include="DigitalData.Core.Abstraction.Application" Version="1.5.0" />
|
||||||
|
<PackageReference Include="DigitalData.Core.Application" Version="3.4.0" />
|
||||||
|
<PackageReference Include="DigitalData.Core.Exceptions" Version="1.1.0" />
|
||||||
<PackageReference Include="MediatR" Version="13.1.0" />
|
<PackageReference Include="MediatR" Version="13.1.0" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.11" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@ -1,9 +1,27 @@
|
|||||||
using MediatR;
|
using MediatR;
|
||||||
using ReC.Application.Dto;
|
using ReC.Application.Dto;
|
||||||
|
using DigitalData.Core.Abstraction.Application.Repository;
|
||||||
|
using ReC.Domain.Entities;
|
||||||
|
using AutoMapper;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using DigitalData.Core.Exceptions;
|
||||||
|
|
||||||
namespace ReC.Application.RecActions.Queries;
|
namespace ReC.Application.RecActions.Queries;
|
||||||
|
|
||||||
public class ReadRecActionQuery : IRequest<IEnumerable<RecActionDto>>
|
public class ReadRecActionQuery : IRequest<IEnumerable<RecActionDto>>
|
||||||
{
|
{
|
||||||
public int ProfileId { get; init; }
|
public int ProfileId { get; init; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ReadRecActionQueryHandler(IRepository<RecAction> repo, IMapper mapper) : IRequestHandler<ReadRecActionQuery, IEnumerable<RecActionDto>>
|
||||||
|
{
|
||||||
|
public async Task<IEnumerable<RecActionDto>> Handle(ReadRecActionQuery request, CancellationToken cancel)
|
||||||
|
{
|
||||||
|
var actions = await repo.Where(x => x.ProfileId == request.ProfileId).ToListAsync(cancel);
|
||||||
|
|
||||||
|
if(actions.Count != 0)
|
||||||
|
throw new NotFoundException($"No actions found for the profile {request.ProfileId}.");
|
||||||
|
|
||||||
|
return mapper.Map<IEnumerable<RecActionDto>>(actions);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user