diff --git a/src/ReC.Application/ReC.Application.csproj b/src/ReC.Application/ReC.Application.csproj index a9766be..103d5b3 100644 --- a/src/ReC.Application/ReC.Application.csproj +++ b/src/ReC.Application/ReC.Application.csproj @@ -8,7 +8,11 @@ + + + + diff --git a/src/ReC.Application/RecActions/Queries/ReadRecActionQuery.cs b/src/ReC.Application/RecActions/Queries/ReadRecActionQuery.cs index f0e9751..bc023d8 100644 --- a/src/ReC.Application/RecActions/Queries/ReadRecActionQuery.cs +++ b/src/ReC.Application/RecActions/Queries/ReadRecActionQuery.cs @@ -1,9 +1,27 @@ using MediatR; 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; public class ReadRecActionQuery : IRequest> { public int ProfileId { get; init; } +} + +public class ReadRecActionQueryHandler(IRepository repo, IMapper mapper) : IRequestHandler> +{ + public async Task> 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>(actions); + } } \ No newline at end of file