Updated the namespaces for BodyQueryBehavior and HeaderQueryBehavior from ReC.Application.Common.Behaviors to ReC.Application.Common.Behaviors.Action. Adjusted related imports in DependencyInjection.cs to reflect this change for improved code organization.
24 lines
775 B
C#
24 lines
775 B
C#
using MediatR;
|
|
using ReC.Application.Common.Dto;
|
|
using ReC.Application.Common.Interfaces;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace ReC.Application.Common.Behaviors.Action;
|
|
|
|
public class BodyQueryBehavior<TRequest, TResponse>(IRecDbContext dbContext) : IPipelineBehavior<TRequest, TResponse>
|
|
where TRequest : RecActionViewDto
|
|
where TResponse : notnull
|
|
{
|
|
public async Task<TResponse> Handle(TRequest action, RequestHandlerDelegate<TResponse> next, CancellationToken cancel)
|
|
{
|
|
if (action.BodyQuery is null)
|
|
return await next(cancel);
|
|
|
|
var result = await dbContext.BodyQueryResults.FromSqlRaw(action.BodyQuery).SingleOrDefaultAsync(cancel);
|
|
|
|
action.Body = result?.RawBody;
|
|
|
|
return await next(cancel);
|
|
}
|
|
}
|