Refactor RecAction commands and queries to use records

Refactored `InvokeRecActionCommand` and `ReadRecActionQuery`
to leverage C# `record` types for immutability and improved
data structure clarity. Introduced `ReadRecActionQueryBase`
as a shared base record to separate common properties and
logic. Updated `InvokeRecActionCommandHandler` to use the
new `ToReadQuery` method for compatibility. These changes
enhance code maintainability, reusability, and separation
of concerns while preserving existing functionality.
This commit is contained in:
2025-11-27 10:56:21 +01:00
parent cd8f757c43
commit cb851a4ec6
2 changed files with 7 additions and 5 deletions

View File

@@ -4,9 +4,7 @@ using ReC.Application.RecActions.Queries;
namespace ReC.Application.RecActions.Commands;
public class InvokeRecActionCommand : ReadRecActionQuery, IRequest
{
}
public record InvokeRecActionCommand : ReadRecActionQueryBase, IRequest;
public static class InvokeRecActionCommandExtensions
{
@@ -18,7 +16,7 @@ public class InvokeRecActionCommandHandler(ISender sender, IHttpClientFactory cl
{
public async Task Handle(InvokeRecActionCommand request, CancellationToken cancel)
{
var actions = await sender.Send(request as ReadRecActionQuery, cancel);
var actions = await sender.Send(request.ToReadQuery(), cancel);
var http = clientFactory.CreateClient();