Refactor query handling for dynamic customization
Updated `InvokeBatchRecActionsCommandExtensions` to filter actions with `Invoked = false` using a lambda in `ToReadQuery`. Refactored `ReadRecActionQueryBase` to remove the `Invoked` property and updated `ToReadQuery` to accept a delegate for external query modifications. Moved the `Invoked` property to `ReadRecActionQuery` and added a parameterless constructor. These changes improve flexibility and enable dynamic query customization.
This commit is contained in:
parent
34d0741ac8
commit
c41c394f48
@ -17,7 +17,7 @@ public class InvokeRecActionsCommandHandler(ISender sender, IServiceScopeFactory
|
|||||||
{
|
{
|
||||||
public async Task Handle(InvokeBatchRecActionsCommand request, CancellationToken cancel)
|
public async Task Handle(InvokeBatchRecActionsCommand request, CancellationToken cancel)
|
||||||
{
|
{
|
||||||
var actions = await sender.Send(request.ToReadQuery(), cancel);
|
var actions = await sender.Send(request.ToReadQuery(q => q.Invoked = false), cancel);
|
||||||
|
|
||||||
var http = clientFactory.CreateClient();
|
var http = clientFactory.CreateClient();
|
||||||
|
|
||||||
|
|||||||
@ -12,15 +12,20 @@ public record ReadRecActionQueryBase
|
|||||||
{
|
{
|
||||||
public long ProfileId { get; init; }
|
public long ProfileId { get; init; }
|
||||||
|
|
||||||
public bool? Invoked { get; set; } = null;
|
public ReadRecActionQuery ToReadQuery(Action<ReadRecActionQuery> modify)
|
||||||
|
{
|
||||||
public ReadRecActionQuery ToReadQuery() => new(this);
|
ReadRecActionQuery query = new(this);
|
||||||
|
modify(query);
|
||||||
|
return query;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public record ReadRecActionQuery : ReadRecActionQueryBase, IRequest<IEnumerable<RecActionDto>>
|
public record ReadRecActionQuery : ReadRecActionQueryBase, IRequest<IEnumerable<RecActionDto>>
|
||||||
{
|
{
|
||||||
public ReadRecActionQuery(ReadRecActionQueryBase root) : base(root) { }
|
public ReadRecActionQuery(ReadRecActionQueryBase root) : base(root) { }
|
||||||
|
|
||||||
|
public bool? Invoked { get; set; } = null;
|
||||||
|
|
||||||
public ReadRecActionQuery() { }
|
public ReadRecActionQuery() { }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user