From 71a0220c3f642c36245ad4b99212b32734408776 Mon Sep 17 00:00:00 2001 From: TekH Date: Fri, 12 Dec 2025 15:04:43 +0100 Subject: [PATCH] Refactor: replace RecActionDto with RecActionViewDto Standardize usage of RecActionViewDto across the codebase: - Update pipeline behaviors, mapping profiles, and commands to use RecActionViewDto. - Remove RecActionDto and introduce RecActionViewDto with equivalent properties and methods. - Adjust query handlers and related interfaces to work with RecActionViewDto. This clarifies DTO usage and aligns the model with domain intent. --- src/ReC.Application/Common/Behaviors/BodyQueryBehavior.cs | 2 +- .../Common/Behaviors/HeaderQueryBehavior.cs | 2 +- src/ReC.Application/Common/Dto/DtoMappingProfile.cs | 2 +- .../Common/Dto/{RecActionDto.cs => RecActionViewDto.cs} | 2 +- .../RecActionViews/Commands/InvokeRecActionViewCommand.cs | 4 ++-- .../RecActionViews/Queries/ReadRecActionViewQuery.cs | 8 ++++---- 6 files changed, 10 insertions(+), 10 deletions(-) rename src/ReC.Application/Common/Dto/{RecActionDto.cs => RecActionViewDto.cs} (98%) diff --git a/src/ReC.Application/Common/Behaviors/BodyQueryBehavior.cs b/src/ReC.Application/Common/Behaviors/BodyQueryBehavior.cs index f79c145..8596e4e 100644 --- a/src/ReC.Application/Common/Behaviors/BodyQueryBehavior.cs +++ b/src/ReC.Application/Common/Behaviors/BodyQueryBehavior.cs @@ -6,7 +6,7 @@ using Microsoft.EntityFrameworkCore; namespace ReC.Application.Common.Behaviors; public class BodyQueryBehavior(IRecDbContext dbContext) : IPipelineBehavior - where TRequest : RecActionDto + where TRequest : RecActionViewDto where TResponse : notnull { public async Task Handle(TRequest action, RequestHandlerDelegate next, CancellationToken cancel) diff --git a/src/ReC.Application/Common/Behaviors/HeaderQueryBehavior.cs b/src/ReC.Application/Common/Behaviors/HeaderQueryBehavior.cs index b154301..2b703b4 100644 --- a/src/ReC.Application/Common/Behaviors/HeaderQueryBehavior.cs +++ b/src/ReC.Application/Common/Behaviors/HeaderQueryBehavior.cs @@ -8,7 +8,7 @@ using System.Text.Json; namespace ReC.Application.Common.Behaviors; public class HeaderQueryBehavior(IRecDbContext dbContext, ILogger>? logger = null) : IPipelineBehavior - where TRequest : RecActionDto + where TRequest : RecActionViewDto where TResponse : notnull { public async Task Handle(TRequest action, RequestHandlerDelegate next, CancellationToken cancel) diff --git a/src/ReC.Application/Common/Dto/DtoMappingProfile.cs b/src/ReC.Application/Common/Dto/DtoMappingProfile.cs index ddf6e99..c4b67ee 100644 --- a/src/ReC.Application/Common/Dto/DtoMappingProfile.cs +++ b/src/ReC.Application/Common/Dto/DtoMappingProfile.cs @@ -6,7 +6,7 @@ public class DtoMappingProfile : AutoMapper.Profile { public DtoMappingProfile() { - CreateMap(); + CreateMap(); CreateMap(); } } diff --git a/src/ReC.Application/Common/Dto/RecActionDto.cs b/src/ReC.Application/Common/Dto/RecActionViewDto.cs similarity index 98% rename from src/ReC.Application/Common/Dto/RecActionDto.cs rename to src/ReC.Application/Common/Dto/RecActionViewDto.cs index f94e61e..ec5c344 100644 --- a/src/ReC.Application/Common/Dto/RecActionDto.cs +++ b/src/ReC.Application/Common/Dto/RecActionViewDto.cs @@ -3,7 +3,7 @@ using ReC.Domain.Constants; namespace ReC.Application.Common.Dto; -public record RecActionDto +public record RecActionViewDto { public required long Id { get; init; } diff --git a/src/ReC.Application/RecActionViews/Commands/InvokeRecActionViewCommand.cs b/src/ReC.Application/RecActionViews/Commands/InvokeRecActionViewCommand.cs index dacedaf..2f790f1 100644 --- a/src/ReC.Application/RecActionViews/Commands/InvokeRecActionViewCommand.cs +++ b/src/ReC.Application/RecActionViews/Commands/InvokeRecActionViewCommand.cs @@ -15,12 +15,12 @@ namespace ReC.Application.RecActionViews.Commands; public record InvokeRecActionViewCommand : IRequest { - public RecActionDto Action { get; set; } = null!; + public RecActionViewDto Action { get; set; } = null!; } public static class InvokeRecActionViewCommandExtensions { - public static InvokeRecActionViewCommand ToInvokeCommand(this RecActionDto dto) => new() { Action = dto }; + public static InvokeRecActionViewCommand ToInvokeCommand(this RecActionViewDto dto) => new() { Action = dto }; } public class InvokeRecActionViewCommandHandler( diff --git a/src/ReC.Application/RecActionViews/Queries/ReadRecActionViewQuery.cs b/src/ReC.Application/RecActionViews/Queries/ReadRecActionViewQuery.cs index 2802e91..6f08bea 100644 --- a/src/ReC.Application/RecActionViews/Queries/ReadRecActionViewQuery.cs +++ b/src/ReC.Application/RecActionViews/Queries/ReadRecActionViewQuery.cs @@ -20,7 +20,7 @@ public record ReadRecActionQueryBase } } -public record ReadRecActionViewQuery : ReadRecActionQueryBase, IRequest> +public record ReadRecActionViewQuery : ReadRecActionQueryBase, IRequest> { public ReadRecActionViewQuery(ReadRecActionQueryBase root) : base(root) { } @@ -29,9 +29,9 @@ public record ReadRecActionViewQuery : ReadRecActionQueryBase, IRequest repo, IMapper mapper) : IRequestHandler> +public class ReadRecActionViewQueryHandler(IRepository repo, IMapper mapper) : IRequestHandler> { - public async Task> Handle(ReadRecActionViewQuery request, CancellationToken cancel) + public async Task> Handle(ReadRecActionViewQuery request, CancellationToken cancel) { var query = repo.Where(act => act.ProfileId == request.ProfileId); @@ -43,6 +43,6 @@ public class ReadRecActionViewQueryHandler(IRepository repo, IMap if (actions.Count == 0) throw new NotFoundException($"No actions found for the profile {request.ProfileId}."); - return mapper.Map>(actions); + return mapper.Map>(actions); } } \ No newline at end of file