Update behavior namespaces to InvokeAction for clarity

Renamed namespaces in PreprocessingBehavior and PostprocessingBehavior from .Action to .InvokeAction, and updated related using directives in DependencyInjection.cs. Added a folder entry for Common\Behaviors\Action\ in the project file for organization.
This commit is contained in:
2026-03-25 11:43:30 +01:00
parent aef59def7f
commit 90e8adbd36
4 changed files with 7 additions and 3 deletions

View File

@@ -0,0 +1,44 @@
using MediatR;
using ReC.Application.Common.Exceptions;
using ReC.Application.Common.Interfaces;
using ReC.Application.RecActions.Commands;
using ReC.Application.Results.Commands;
using ReC.Domain.Constants;
using System.Text.Json;
namespace ReC.Application.Common.Behaviors.InvokeAction;
public class PreprocessingBehavior(IRecDbContext context, ISender sender) : IPipelineBehavior<InvokeRecActionViewCommand, Unit>
{
public async Task<Unit> Handle(InvokeRecActionViewCommand request, RequestHandlerDelegate<Unit> next, CancellationToken cancel)
{
try
{
if (request.Action.PreprocessingQuery is string query)
{
var result = await context.ExecuteDynamicSqlAsync(query, cancel);
await sender.Send(new InsertResultCommand()
{
ActionId = request.Action.Id,
Info = JsonSerializer.Serialize(result),
Type = ResultType.Pre
}, cancel);
}
}
catch (Exception ex)
{
await sender.Send(new InsertResultCommand()
{
ActionId = request.Action.Id,
Error = ex.ToString(),
Type = ResultType.Pre
}, cancel);
if (request.Action.ErrorAction == ErrorAction.Stop)
throw new RecActionException(request.Action.Id, request.Action.ProfileId, ex);
}
return await next(cancel);
}
}