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:
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user