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.
This commit is contained in:
2025-12-12 15:04:43 +01:00
parent f53603083a
commit 71a0220c3f
6 changed files with 10 additions and 10 deletions

View File

@@ -6,7 +6,7 @@ using Microsoft.EntityFrameworkCore;
namespace ReC.Application.Common.Behaviors;
public class BodyQueryBehavior<TRequest, TResponse>(IRecDbContext dbContext) : IPipelineBehavior<TRequest, TResponse>
where TRequest : RecActionDto
where TRequest : RecActionViewDto
where TResponse : notnull
{
public async Task<TResponse> Handle(TRequest action, RequestHandlerDelegate<TResponse> next, CancellationToken cancel)

View File

@@ -8,7 +8,7 @@ using System.Text.Json;
namespace ReC.Application.Common.Behaviors;
public class HeaderQueryBehavior<TRequest, TResponse>(IRecDbContext dbContext, ILogger<HeaderQueryBehavior<TRequest, TResponse>>? logger = null) : IPipelineBehavior<TRequest, TResponse>
where TRequest : RecActionDto
where TRequest : RecActionViewDto
where TResponse : notnull
{
public async Task<TResponse> Handle(TRequest action, RequestHandlerDelegate<TResponse> next, CancellationToken cancel)

View File

@@ -6,7 +6,7 @@ public class DtoMappingProfile : AutoMapper.Profile
{
public DtoMappingProfile()
{
CreateMap<RecActionView, RecActionDto>();
CreateMap<RecActionView, RecActionViewDto>();
CreateMap<OutRes, OutResDto>();
}
}

View File

@@ -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; }

View File

@@ -15,12 +15,12 @@ namespace ReC.Application.RecActionViews.Commands;
public record InvokeRecActionViewCommand : IRequest<bool>
{
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(

View File

@@ -20,7 +20,7 @@ public record ReadRecActionQueryBase
}
}
public record ReadRecActionViewQuery : ReadRecActionQueryBase, IRequest<IEnumerable<RecActionDto>>
public record ReadRecActionViewQuery : ReadRecActionQueryBase, IRequest<IEnumerable<RecActionViewDto>>
{
public ReadRecActionViewQuery(ReadRecActionQueryBase root) : base(root) { }
@@ -29,9 +29,9 @@ public record ReadRecActionViewQuery : ReadRecActionQueryBase, IRequest<IEnumera
public ReadRecActionViewQuery() { }
}
public class ReadRecActionViewQueryHandler(IRepository<RecActionView> repo, IMapper mapper) : IRequestHandler<ReadRecActionViewQuery, IEnumerable<RecActionDto>>
public class ReadRecActionViewQueryHandler(IRepository<RecActionView> repo, IMapper mapper) : IRequestHandler<ReadRecActionViewQuery, IEnumerable<RecActionViewDto>>
{
public async Task<IEnumerable<RecActionDto>> Handle(ReadRecActionViewQuery request, CancellationToken cancel)
public async Task<IEnumerable<RecActionViewDto>> Handle(ReadRecActionViewQuery request, CancellationToken cancel)
{
var query = repo.Where(act => act.ProfileId == request.ProfileId);
@@ -43,6 +43,6 @@ public class ReadRecActionViewQueryHandler(IRepository<RecActionView> repo, IMap
if (actions.Count == 0)
throw new NotFoundException($"No actions found for the profile {request.ProfileId}.");
return mapper.Map<IEnumerable<RecActionDto>>(actions);
return mapper.Map<IEnumerable<RecActionViewDto>>(actions);
}
}