From 20ca2c2e48ee6476816b2df599202c0459d1ec0f Mon Sep 17 00:00:00 2001 From: Developer 02 Date: Wed, 26 Nov 2025 17:12:30 +0100 Subject: [PATCH] init ReadRecAction query --- src/ReC.Application/ReC.Application.csproj | 4 ++++ .../RecActions/Queries/ReadRecActionQuery.cs | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+) 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