Refactor BodyQueryBehavior for generic request-response

Updated BodyQueryBehavior to support a generic request-response
pipeline. Replaced fixed `TRecAction` and `Unit` types with
`TRequest` and `TResponse` generics. Added `where` constraints
for `TRequest` (`RecActionDto`) and `TResponse` (`notnull`).
Updated the `Handle` method signature and return type to align
with the new generics.
This commit is contained in:
tekh 2025-12-03 10:12:35 +01:00
parent 269578194a
commit 3998c9ce0b

View File

@ -5,10 +5,11 @@ using Microsoft.EntityFrameworkCore;
namespace ReC.Application.Common.Behaviors; namespace ReC.Application.Common.Behaviors;
public class BodyQueryBehavior<TRecAction>(IRecDbContext dbContext) : IPipelineBehavior<TRecAction, Unit> public class BodyQueryBehavior<TRequest, TResponse>(IRecDbContext dbContext) : IPipelineBehavior<TRequest, TResponse>
where TRecAction : RecActionDto where TRequest : RecActionDto
where TResponse : notnull
{ {
public async Task<Unit> Handle(TRecAction action, RequestHandlerDelegate<Unit> next, CancellationToken cancel) public async Task<TResponse> Handle(TRequest action, RequestHandlerDelegate<TResponse> next, CancellationToken cancel)
{ {
if (action.BodyQuery is null) if (action.BodyQuery is null)
return await next(cancel); return await next(cancel);