21 Commits

Author SHA1 Message Date
894b7bb070 Improve error handling and resource cleanup in action handler
Refactored InvokeRecActionViewCommandHandler to enhance error handling by logging exceptions and conditionally rethrowing based on ErrorAction. Simplified NTLM HttpClient/handler management for proper disposal. Improved code structure and formatting for clarity.
2026-03-24 17:02:06 +01:00
a707cce6e4 Refactor error handling in Pre/Postprocessing behaviors
Refactored PreprocessingBehavior and PostprocessingBehavior to send InsertResultCommand with only relevant info or error fields. Now throws exceptions when ErrorAction is Stop, allowing upstream error handling and preventing unnecessary or misleading result data. Improves consistency and clarity in error processing.
2026-03-24 16:19:00 +01:00
2ca85a2372 Refactor action behaviors to use Unit instead of bool
Refactored PreprocessingBehavior and PostprocessingBehavior for InvokeRecActionViewCommand to use MediatR's Unit as the response type instead of bool. Updated method signatures, return values, and DI registration accordingly to align with MediatR conventions for commands without return values.
2026-03-24 16:01:24 +01:00
dbe09cd07b Refactor error handling in RecActionView invocation
Switch to exception-based error handling for invoking RecActionView actions, removing boolean return values and related checks. Update command and handler signatures to use void return type. Clean up unused using directives. This improves clarity and robustness of error management during batch processing.
2026-03-24 16:00:47 +01:00
690dcea7a8 Add PostprocessingBehavior to MediatR pipeline
Registered PostprocessingBehavior for InvokeRecActionViewCommand (with bool result) in the MediatR pipeline via DependencyInjection. This ensures both preprocessing and postprocessing behaviors are executed for this command.
2026-03-24 14:41:41 +01:00
fdae4d26be Add PostprocessingBehavior for action result logging
Introduced PostprocessingBehavior as an IPipelineBehavior for InvokeRecActionViewCommand. This behavior handles post-processing by executing optional queries, serializing results, and logging outcomes via InsertResultCommand. It also manages error handling based on the action's ErrorAction setting, ensuring consistent result tracking after command execution.
2026-03-24 14:40:52 +01:00
2883cf9be4 Add PreprocessingBehavior for InvokeRecActionViewCommand
Register PreprocessingBehavior in the MediatR pipeline specifically for InvokeRecActionViewCommand. Update using directives to reflect the shift from Procedures to Commands and from Common.Behaviors to Common.Behaviors.Action.
2026-03-24 14:15:01 +01:00
9410c5dc0d Refactor PreprocessingBehavior to log results and errors
Refactored PreprocessingBehavior to serialize and log the results and errors of preprocessing SQL queries using InsertResultCommand. Now records both successful and failed executions, while preserving the stop-on-error behavior. Cleaned up and updated using directives.
2026-03-24 14:01:45 +01:00
35e99d9f2a Change ExecuteDynamicSqlAsync to return object list
The ExecuteDynamicSqlAsync method now returns an IEnumerable of
dictionaries representing query result rows, instead of a JSON
string. This allows consumers to work directly with the data
in its native .NET object form.
2026-03-24 13:26:10 +01:00
5fd65e52a3 Pass CancellationToken to ExecuteDynamicSqlAsync
Updated PreprocessingBehavior to include the CancellationToken when calling ExecuteDynamicSqlAsync, enabling query execution to be cancelled if the operation is aborted.
2026-03-24 13:21:40 +01:00
2508a8b986 Add CancellationToken to ExecuteDynamicSqlAsync method
The ExecuteDynamicSqlAsync extension for IRecDbContext now accepts an optional CancellationToken, which is passed to all async database operations to support cancellation. Also added a TODO to move this method to Common.Infrastructure in the future.
2026-03-24 13:21:05 +01:00
daff1477be Refactor PUT endpoints to use id in route and DTO in body
Refactored update (PUT) endpoints in multiple controllers to accept the record id as a route parameter and the update data as a DTO in the request body. Updated method signatures, XML documentation, and imports to align with RESTful conventions and improve API clarity. Controller methods now construct command objects using the id and DTO before sending to MediatR.
2026-03-24 12:07:50 +01:00
dcfa47c68d Update DELETE endpoints to use [FromQuery] parameters
Refactored all relevant controller DELETE actions to accept command/procedure parameters from the query string ([FromQuery]) instead of the request body ([FromBody]). Updated XML documentation and method signatures to reflect this change, including renaming parameters from "procedure" to "command" where appropriate. Also removed the unused IConfiguration dependency from EndpointAuthController.
2026-03-24 11:57:53 +01:00
e691faf620 Rename Result*Procedure to Result*Command for consistency
Refactor all Result-related procedure records, handlers, and usages to use the *Command suffix instead of *Procedure. Update controller actions, handler interfaces, tests, and InsertObjectProcedure accordingly. No functional changes; improves naming consistency across the codebase.
2026-03-24 11:40:28 +01:00
cac33c46df Rename *ActionProcedure classes to *ActionCommand
Renamed InsertActionProcedure, UpdateActionProcedure, and DeleteActionProcedure to their respective *ActionCommand counterparts to align with CQRS conventions. Updated all controller actions, handlers, tests, and related usages accordingly. No changes to business logic or method signatures.
2026-03-24 11:39:55 +01:00
de503cac5b Rename Profile*Procedure types to Profile*Command for clarity
Renamed InsertProfileProcedure, UpdateProfileProcedure, and DeleteProfileProcedure (and their handlers) to use the "Command" suffix for consistency. Updated all usages in controllers, handlers, and tests. No logic changes; only type names were updated for improved clarity.
2026-03-24 11:39:04 +01:00
4999beda3b Refactor endpoint Procedures to Commands for CQRS alignment
Renamed Insert/Update/DeleteEndpointProcedure classes to their
respective Command counterparts to follow CQRS conventions.
Updated controller actions, handlers, InsertObjectProcedure,
and related unit tests to use the new Command types.
No functional changes were made; this is a naming refactor.
2026-03-24 11:38:22 +01:00
5df36d94e0 Rename EndpointParams procedures to commands for CQRS clarity
Renamed Insert/Update/DeleteEndpointParamsProcedure classes and
handlers to use the "Command" suffix (e.g., InsertEndpointParamsCommand)
for consistency with CQRS conventions. Updated all controller actions,
handlers, and tests to use the new command names. This improves
clarity and aligns naming with standard command patterns.
2026-03-24 11:37:30 +01:00
d3d24a0fb6 Refactor: Rename UpdateEndpointAuthProcedure to Command
Renamed UpdateEndpointAuthProcedure to UpdateEndpointAuthCommand across the codebase for improved naming consistency. Updated controller, handler, and tests to use the new command name, aligning with CQRS conventions for state-modifying operations.
2026-03-24 11:36:49 +01:00
a6b0cbaf9d Rename InsertEndpointAuthProcedure to InsertEndpointAuthCommand
Refactored all usages of InsertEndpointAuthProcedure to InsertEndpointAuthCommand, including method signatures, handler interfaces, and test cases, to better align with CQRS naming conventions for write operations.
2026-03-24 11:35:58 +01:00
0162d059da Refactor: Rename DeleteEndpointAuthProcedure to Command
Renamed DeleteEndpointAuthProcedure to DeleteEndpointAuthCommand across the codebase, including controller, handler, and tests, to improve naming consistency and align with CQRS conventions for write operations.
2026-03-24 11:31:33 +01:00
39 changed files with 264 additions and 183 deletions

View File

@@ -25,7 +25,7 @@ public class CommonController(IMediator mediator) : ControllerBase
}
[HttpDelete]
public async Task<IActionResult> DeleteObject([FromBody] DeleteObjectProcedure procedure, CancellationToken cancel)
public async Task<IActionResult> DeleteObject([FromQuery] DeleteObjectProcedure procedure, CancellationToken cancel)
{
var result = await mediator.Send(procedure, cancel);
return Ok(result);

View File

@@ -1,12 +1,13 @@
using MediatR;
using Microsoft.AspNetCore.Mvc;
using ReC.Application.Common.Procedures.UpdateProcedure.Dto;
using ReC.Application.EndpointAuth.Commands;
namespace ReC.API.Controllers;
[Route("api/[controller]")]
[ApiController]
public class EndpointAuthController(IMediator mediator, IConfiguration config) : ControllerBase
public class EndpointAuthController(IMediator mediator) : ControllerBase
{
/// <summary>
/// Inserts an endpoint authentication record via the ENDPOINT_AUTH insert procedure.
@@ -16,7 +17,7 @@ public class EndpointAuthController(IMediator mediator, IConfiguration config) :
/// <returns>The created ENDPOINT_AUTH identifier.</returns>
[HttpPost]
[ProducesResponseType(StatusCodes.Status201Created)]
public async Task<IActionResult> Post([FromBody] InsertEndpointAuthProcedure procedure, CancellationToken cancel)
public async Task<IActionResult> Post([FromBody] InsertEndpointAuthCommand procedure, CancellationToken cancel)
{
var id = await mediator.Send(procedure, cancel);
return StatusCode(StatusCodes.Status201Created, id);
@@ -25,28 +26,29 @@ public class EndpointAuthController(IMediator mediator, IConfiguration config) :
/// <summary>
/// Updates an endpoint authentication record via the ENDPOINT_AUTH update procedure.
/// </summary>
/// <param name="procedure">UpdateEndpointAuthProcedure payload.</param>
/// <param name="id">The identifier of the ENDPOINT_AUTH record to update.</param>
/// <param name="data">UpdateEndpointAuthProcedure payload.</param>
/// <param name="cancel">A token to cancel the operation.</param>
/// <returns>No content on success.</returns>
[HttpPut]
[HttpPut("{id:long}")]
[ProducesResponseType(StatusCodes.Status204NoContent)]
public async Task<IActionResult> Put([FromBody] UpdateEndpointAuthProcedure procedure, CancellationToken cancel)
public async Task<IActionResult> Put([FromRoute] long id, [FromBody] UpdateEndpointAuthDto data, CancellationToken cancel)
{
await mediator.Send(procedure, cancel);
await mediator.Send(new UpdateEndpointAuthCommand() { Id = id, Data = data}, cancel);
return NoContent();
}
/// <summary>
/// Deletes endpoint authentication records via the ENDPOINT_AUTH delete procedure for the specified id range.
/// </summary>
/// <param name="procedure">DeleteEndpointAuthProcedure payload (Start, End, Force).</param>
/// <param name="command">DeleteEndpointAuthProcedure payload (Start, End, Force).</param>
/// <param name="cancel">A token to cancel the operation.</param>
/// <returns>No content on success.</returns>
[HttpDelete]
[ProducesResponseType(StatusCodes.Status204NoContent)]
public async Task<IActionResult> Delete([FromBody] DeleteEndpointAuthProcedure procedure, CancellationToken cancel)
public async Task<IActionResult> Delete([FromQuery] DeleteEndpointAuthCommand command, CancellationToken cancel)
{
await mediator.Send(procedure, cancel);
await mediator.Send(command, cancel);
return NoContent();
}
}

View File

@@ -1,5 +1,6 @@
using MediatR;
using Microsoft.AspNetCore.Mvc;
using ReC.Application.Common.Procedures.UpdateProcedure.Dto;
using ReC.Application.EndpointParams.Commands;
namespace ReC.API.Controllers;
@@ -16,7 +17,7 @@ public class EndpointParamsController(IMediator mediator) : ControllerBase
/// <returns>The created ENDPOINT_PARAMS identifier.</returns>
[HttpPost]
[ProducesResponseType(StatusCodes.Status201Created)]
public async Task<IActionResult> Post([FromBody] InsertEndpointParamsProcedure procedure, CancellationToken cancel)
public async Task<IActionResult> Post([FromBody] InsertEndpointParamsCommand procedure, CancellationToken cancel)
{
var id = await mediator.Send(procedure, cancel);
return StatusCode(StatusCodes.Status201Created, id);
@@ -25,28 +26,29 @@ public class EndpointParamsController(IMediator mediator) : ControllerBase
/// <summary>
/// Updates endpoint parameter records via the ENDPOINT_PARAMS update procedure.
/// </summary>
/// <param name="procedure">UpdateEndpointParamsProcedure payload.</param>
/// <param name="id">The identifier of the ENDPOINT_PARAMS record to update.</param>
/// <param name="data">UpdateEndpointParamsProcedure payload.</param>
/// <param name="cancel">A token to cancel the operation.</param>
/// <returns>No content on success.</returns>
[HttpPut]
[HttpPut("{id:long}")]
[ProducesResponseType(StatusCodes.Status204NoContent)]
public async Task<IActionResult> Put([FromBody] UpdateEndpointParamsProcedure procedure, CancellationToken cancel)
public async Task<IActionResult> Put([FromRoute] long id, [FromBody] UpdateEndpointParamsDto data, CancellationToken cancel)
{
await mediator.Send(procedure, cancel);
await mediator.Send(new UpdateEndpointParamsCommand() { Id = id, Data = data }, cancel);
return NoContent();
}
/// <summary>
/// Deletes endpoint parameter records via the ENDPOINT_PARAMS delete procedure for the specified id range.
/// </summary>
/// <param name="procedure">DeleteEndpointParamsProcedure payload (Start, End, Force).</param>
/// <param name="command">DeleteEndpointParamsProcedure payload (Start, End, Force).</param>
/// <param name="cancel">A token to cancel the operation.</param>
/// <returns>No content on success.</returns>
[HttpDelete]
[ProducesResponseType(StatusCodes.Status204NoContent)]
public async Task<IActionResult> Delete([FromBody] DeleteEndpointParamsProcedure procedure, CancellationToken cancel)
public async Task<IActionResult> Delete([FromQuery] DeleteEndpointParamsCommand command, CancellationToken cancel)
{
await mediator.Send(procedure, cancel);
await mediator.Send(command, cancel);
return NoContent();
}
}

View File

@@ -1,5 +1,6 @@
using MediatR;
using Microsoft.AspNetCore.Mvc;
using ReC.Application.Common.Procedures.UpdateProcedure.Dto;
using ReC.Application.Endpoints.Commands;
namespace ReC.API.Controllers;
@@ -16,7 +17,7 @@ public class EndpointsController(IMediator mediator) : ControllerBase
/// <returns>The created ENDPOINT identifier.</returns>
[HttpPost]
[ProducesResponseType(StatusCodes.Status201Created)]
public async Task<IActionResult> Post([FromBody] InsertEndpointProcedure procedure, CancellationToken cancel)
public async Task<IActionResult> Post([FromBody] InsertEndpointCommand procedure, CancellationToken cancel)
{
var id = await mediator.Send(procedure, cancel);
return StatusCode(StatusCodes.Status201Created, id);
@@ -25,28 +26,29 @@ public class EndpointsController(IMediator mediator) : ControllerBase
/// <summary>
/// Updates an endpoint via the ENDPOINT update procedure.
/// </summary>
/// <param name="procedure">UpdateEndpointProcedure payload.</param>
/// <param name="id">The identifier of the ENDPOINT record to update.</param>
/// <param name="data">UpdateEndpointProcedure payload.</param>
/// <param name="cancel">A token to cancel the operation.</param>
/// <returns>No content on success.</returns>
[HttpPut]
[HttpPut("{id:long}")]
[ProducesResponseType(StatusCodes.Status204NoContent)]
public async Task<IActionResult> Put([FromBody] UpdateEndpointProcedure procedure, CancellationToken cancel)
public async Task<IActionResult> Put([FromRoute] long id, [FromBody] UpdateEndpointDto data, CancellationToken cancel)
{
await mediator.Send(procedure, cancel);
await mediator.Send(new UpdateEndpointCommand() { Id = id, Data = data }, cancel);
return NoContent();
}
/// <summary>
/// Deletes endpoints via the ENDPOINT delete procedure for the specified id range.
/// </summary>
/// <param name="procedure">DeleteEndpointProcedure payload (Start, End, Force).</param>
/// <param name="command">DeleteEndpointProcedure payload (Start, End, Force).</param>
/// <param name="cancel">A token to cancel the operation.</param>
/// <returns>No content on success.</returns>
[HttpDelete]
[ProducesResponseType(StatusCodes.Status204NoContent)]
public async Task<IActionResult> Delete([FromBody] DeleteEndpointProcedure procedure, CancellationToken cancel)
public async Task<IActionResult> Delete([FromQuery] DeleteEndpointCommand command, CancellationToken cancel)
{
await mediator.Send(procedure, cancel);
await mediator.Send(command, cancel);
return NoContent();
}
}
}

View File

@@ -1,5 +1,6 @@
using MediatR;
using Microsoft.AspNetCore.Mvc;
using ReC.Application.Common.Procedures.UpdateProcedure.Dto;
using ReC.Application.Profile.Commands;
using ReC.Application.Profile.Queries;
@@ -23,7 +24,7 @@ public class ProfileController(IMediator mediator) : ControllerBase
/// <returns>The created profile identifier.</returns>
[HttpPost]
[ProducesResponseType(StatusCodes.Status201Created)]
public async Task<IActionResult> Post([FromBody] InsertProfileProcedure procedure, CancellationToken cancel)
public async Task<IActionResult> Post([FromBody] InsertProfileCommand procedure, CancellationToken cancel)
{
var id = await mediator.Send(procedure, cancel);
return CreatedAtAction(nameof(Get), new { id }, id);
@@ -32,28 +33,29 @@ public class ProfileController(IMediator mediator) : ControllerBase
/// <summary>
/// Updates a profile via the PROFILE update procedure.
/// </summary>
/// <param name="procedure">UpdateProfileProcedure payload.</param>
/// <param name="id">The identifier of the PROFILE record to update.</param>
/// <param name="data">UpdateProfileProcedure payload.</param>
/// <param name="cancel">A token to cancel the operation.</param>
/// <returns>No content on success.</returns>
[HttpPut]
[HttpPut("{id:long}")]
[ProducesResponseType(StatusCodes.Status204NoContent)]
public async Task<IActionResult> Put([FromBody] UpdateProfileProcedure procedure, CancellationToken cancel)
public async Task<IActionResult> Put([FromRoute] long id, [FromBody] UpdateProfileDto data, CancellationToken cancel)
{
await mediator.Send(procedure, cancel);
await mediator.Send(new UpdateProfileCommand() { Id = id, Data = data }, cancel);
return NoContent();
}
/// <summary>
/// Deletes profile records via the PROFILE delete procedure for the specified id range.
/// </summary>
/// <param name="procedure">DeleteProfileProcedure payload (Start, End, Force).</param>
/// <param name="command">DeleteProfileProcedure payload (Start, End, Force).</param>
/// <param name="cancel">A token to cancel the operation.</param>
/// <returns>No content on success.</returns>
[HttpDelete]
[ProducesResponseType(StatusCodes.Status204NoContent)]
public async Task<IActionResult> Delete([FromBody] DeleteProfileProcedure procedure, CancellationToken cancel)
public async Task<IActionResult> Delete([FromQuery] DeleteProfileCommand command, CancellationToken cancel)
{
await mediator.Send(procedure, cancel);
await mediator.Send(command, cancel);
return NoContent();
}
}

View File

@@ -1,5 +1,6 @@
using MediatR;
using Microsoft.AspNetCore.Mvc;
using ReC.Application.Common.Procedures.UpdateProcedure.Dto;
using ReC.Application.RecActions.Commands;
using ReC.Application.RecActions.Queries;
@@ -42,7 +43,7 @@ public class RecActionController(IMediator mediator) : ControllerBase
/// <returns>An HTTP 201 Created response.</returns>
[HttpPost]
[ProducesResponseType(StatusCodes.Status201Created)]
public async Task<IActionResult> Create([FromBody] InsertActionProcedure command, CancellationToken cancel)
public async Task<IActionResult> Create([FromBody] InsertActionCommand command, CancellationToken cancel)
{
await mediator.Send(command, cancel);
@@ -52,28 +53,29 @@ public class RecActionController(IMediator mediator) : ControllerBase
/// <summary>
/// Updates a RecAction via the ACTION update procedure.
/// </summary>
/// <param name="procedure">UpdateActionProcedure payload.</param>
/// <param name="id">The identifier of the ACTION record to update.</param>
/// <param name="data">UpdateActionProcedure payload.</param>
/// <param name="cancel">A token to cancel the operation.</param>
/// <returns>No content on success.</returns>
[HttpPut("{id:long}")]
[ProducesResponseType(StatusCodes.Status204NoContent)]
public async Task<IActionResult> Update([FromBody] UpdateActionProcedure procedure, CancellationToken cancel)
public async Task<IActionResult> Update([FromRoute] long id, [FromBody] UpdateActionDto data, CancellationToken cancel)
{
await mediator.Send(procedure, cancel);
await mediator.Send(new UpdateActionCommand() { Id = id, Data = data }, cancel);
return NoContent();
}
/// <summary>
/// Deletes RecActions via the ACTION delete procedure for the specified id range.
/// </summary>
/// <param name="procedure">DeleteActionProcedure payload (Start, End, Force).</param>
/// <param name="command">DeleteActionProcedure payload (Start, End, Force).</param>
/// <param name="cancel">A token to cancel the operation.</param>
/// <returns>An HTTP 204 No Content response upon successful deletion.</returns>
[HttpDelete]
[ProducesResponseType(StatusCodes.Status204NoContent)]
public async Task<IActionResult> Delete([FromBody] DeleteActionProcedure procedure, CancellationToken cancel)
public async Task<IActionResult> Delete([FromQuery] DeleteActionCommand command, CancellationToken cancel)
{
await mediator.Send(procedure, cancel);
await mediator.Send(command, cancel);
return NoContent();
}
#endregion CRUD

View File

@@ -1,8 +1,6 @@
using MediatR;
using Microsoft.AspNetCore.Mvc;
using ReC.Application.Common.Procedures.DeleteProcedure;
using ReC.Application.Common.Procedures.InsertProcedure;
using ReC.Application.Common.Procedures.UpdateProcedure;
using ReC.Application.Common.Procedures.UpdateProcedure.Dto;
using ReC.Application.Results.Commands;
using ReC.Application.Results.Queries;
@@ -30,7 +28,7 @@ public class ResultController(IMediator mediator) : ControllerBase
/// <returns>The created RESULT identifier.</returns>
[HttpPost]
[ProducesResponseType(StatusCodes.Status201Created)]
public async Task<IActionResult> Post([FromBody] InsertResultProcedure procedure, CancellationToken cancel)
public async Task<IActionResult> Post([FromBody] InsertResultCommand procedure, CancellationToken cancel)
{
var id = await mediator.Send(procedure, cancel);
return CreatedAtAction(nameof(Get), new { actionId = procedure.ActionId }, new { id, procedure.ActionId });
@@ -39,28 +37,29 @@ public class ResultController(IMediator mediator) : ControllerBase
/// <summary>
/// Updates a RESULT record via the update procedure.
/// </summary>
/// <param name="procedure">UpdateResultProcedure payload.</param>
/// <param name="id">The identifier of the RESULT record to update.</param>
/// <param name="data">UpdateResultProcedure payload.</param>
/// <param name="cancel">A token to cancel the operation.</param>
/// <returns>No content on success.</returns>
[HttpPut]
[HttpPut("{id:long}")]
[ProducesResponseType(StatusCodes.Status204NoContent)]
public async Task<IActionResult> Put([FromBody] UpdateResultProcedure procedure, CancellationToken cancel)
public async Task<IActionResult> Put([FromRoute] long id, [FromBody] UpdateResultDto data, CancellationToken cancel)
{
await mediator.Send(procedure, cancel);
await mediator.Send(new UpdateResultCommand() { Id = id, Data = data }, cancel);
return NoContent();
}
/// <summary>
/// Deletes RESULT records via the delete procedure for the specified id range.
/// </summary>
/// <param name="procedure">DeleteResultProcedure payload (Start, End, Force).</param>
/// <param name="command">DeleteResultProcedure payload (Start, End, Force).</param>
/// <param name="cancel">A token to cancel the operation.</param>
/// <returns>No content on success.</returns>
[HttpDelete]
[ProducesResponseType(StatusCodes.Status204NoContent)]
public async Task<IActionResult> Delete([FromBody] DeleteResultProcedure procedure, CancellationToken cancel)
public async Task<IActionResult> Delete([FromQuery] DeleteResultCommand command, CancellationToken cancel)
{
await mediator.Send(procedure, cancel);
await mediator.Send(command, cancel);
return NoContent();
}
}

View File

@@ -0,0 +1,46 @@
using MediatR;
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.Action;
public class PostprocessingBehavior(IRecDbContext context, ISender sender) : IPipelineBehavior<InvokeRecActionViewCommand, Unit>
{
public async Task<Unit> Handle(InvokeRecActionViewCommand request, RequestHandlerDelegate<Unit> next, CancellationToken cancel)
{
await next(cancel);
try
{
if (request.Action.PostprocessingQuery is string query)
{
var result = await context.ExecuteDynamicSqlAsync(query, cancel);
var info = JsonSerializer.Serialize(result);
await sender.Send(new InsertResultCommand()
{
ActionId = request.Action.Id,
Info = info
}, cancel);
}
}
catch (Exception ex)
{
var error = ex.ToString();
await sender.Send(new InsertResultCommand()
{
ActionId = request.Action.Id,
Error = error
}, cancel);
if (request.Action.ErrorAction == ErrorAction.Stop)
throw;
}
return Unit.Value;
}
}

View File

@@ -1,27 +1,39 @@
using DigitalData.Core.Abstraction.Application.Repository;
using MediatR;
using MediatR;
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.Action;
public class PreprocessingBehavior(IRecDbContext context, ISender sender) : IPipelineBehavior<InvokeRecActionViewCommand, bool>
public class PreprocessingBehavior(IRecDbContext context, ISender sender) : IPipelineBehavior<InvokeRecActionViewCommand, Unit>
{
public async Task<bool> Handle(InvokeRecActionViewCommand request, RequestHandlerDelegate<bool> next, CancellationToken cancel)
public async Task<Unit> Handle(InvokeRecActionViewCommand request, RequestHandlerDelegate<Unit> next, CancellationToken cancel)
{
try
{
if (request.Action.PreprocessingQuery is string query)
await context.ExecuteDynamicSqlAsync(query);
{
var result = await context.ExecuteDynamicSqlAsync(query, cancel);
await sender.Send(new InsertResultCommand()
{
ActionId = request.Action.Id,
Info = JsonSerializer.Serialize(result)
}, cancel);
}
}
catch (Exception ex)
{
if(request.Action.ErrorAction == ErrorAction.Stop)
await sender.Send(new InsertResultCommand()
{
// save output result
return false;
}
ActionId = request.Action.Id,
Error = ex.ToString()
}, cancel);
if (request.Action.ErrorAction == ErrorAction.Stop)
throw;
}
return await next(cancel);

View File

@@ -29,7 +29,8 @@ public interface IRecDbContext
public static class RecDbContextSaveExtensions
{
public static async Task<string> ExecuteDynamicSqlAsync(this IRecDbContext context, string sql)
//TODO: Once it is finalized, move it to Common.Infrastructure
public static async Task<IEnumerable<Dictionary<string, object?>>> ExecuteDynamicSqlAsync(this IRecDbContext context, string sql, CancellationToken cancel = default)
{
var result = new List<Dictionary<string, object?>>();
@@ -37,10 +38,10 @@ public static class RecDbContextSaveExtensions
command.CommandText = sql;
await context.Database.OpenConnectionAsync();
await context.Database.OpenConnectionAsync(cancel);
using var reader = await command.ExecuteReaderAsync();
while (await reader.ReadAsync())
using var reader = await command.ExecuteReaderAsync(cancel);
while (await reader.ReadAsync(cancel))
{
var row = new Dictionary<string, object?>();
@@ -55,6 +56,6 @@ public static class RecDbContextSaveExtensions
result.Add(row);
}
return JsonSerializer.Serialize(result);
return result;
}
}

View File

@@ -24,12 +24,12 @@ public record InsertObjectProcedure : IRequest<long>
//TODO: update to set in authentication middleware or similar, and remove from procedure properties
internal string? AddedWho { get; private set; } = "ReC.API";
public InsertActionProcedure Action { get; set; } = new();
public InsertEndpointProcedure Endpoint { get; set; } = new();
public InsertEndpointAuthProcedure EndpointAuth { get; set; } = new();
public InsertProfileProcedure Profile { get; set; } = new();
public InsertResultProcedure Result { get; set; } = new();
public InsertEndpointParamsProcedure EndpointParams { get; set; } = new();
public InsertActionCommand Action { get; set; } = new();
public InsertEndpointCommand Endpoint { get; set; } = new();
public InsertEndpointAuthCommand EndpointAuth { get; set; } = new();
public InsertProfileCommand Profile { get; set; } = new();
public InsertResultCommand Result { get; set; } = new();
public InsertEndpointParamsCommand EndpointParams { get; set; } = new();
}
public class InsertObjectProcedureHandler(IRepository repo, IOptionsMonitor<SqlExceptionOptions> sqlExOpt) : IRequestHandler<InsertObjectProcedure, long>

View File

@@ -2,11 +2,11 @@
using MediatR;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using ReC.Application.Common.Behaviors;
using ReC.Application.Common.Behaviors.Action;
using ReC.Application.Common.Constants;
using ReC.Application.Common.Options;
using ReC.Application.Common.Procedures;
using ReC.Application.RecActions.Commands;
using System.Reflection;
namespace ReC.Application;
@@ -35,6 +35,8 @@ public static class DependencyInjection
cfg.RegisterServicesFromAssembly(Assembly.GetExecutingAssembly());
cfg.AddOpenBehaviors([typeof(BodyQueryBehavior<,>), typeof(HeaderQueryBehavior<,>)]);
cfg.AddBehavior(typeof(IPipelineBehavior<,>), typeof(ValidationBehavior<,>));
cfg.AddBehavior(typeof(IPipelineBehavior<InvokeRecActionViewCommand, Unit>), typeof(PostprocessingBehavior));
cfg.AddBehavior(typeof(IPipelineBehavior<InvokeRecActionViewCommand, Unit>), typeof(PreprocessingBehavior));
cfg.LicenseKey = configOpt.LuckyPennySoftwareLicenseKey;
});

View File

@@ -3,7 +3,7 @@ using ReC.Application.Common.Procedures.DeleteProcedure;
namespace ReC.Application.EndpointAuth.Commands;
public record DeleteEndpointAuthProcedure : IDeleteProcedure
public record DeleteEndpointAuthCommand : IDeleteProcedure
{
/// <summary>
/// Start GUID/ID (inclusive)
@@ -21,9 +21,9 @@ public record DeleteEndpointAuthProcedure : IDeleteProcedure
public bool Force { get; set; }
}
public class DeleteEndpointAuthProcedureHandler(ISender sender) : IRequestHandler<DeleteEndpointAuthProcedure, int>
public class DeleteEndpointAuthProcedureHandler(ISender sender) : IRequestHandler<DeleteEndpointAuthCommand, int>
{
public async Task<int> Handle(DeleteEndpointAuthProcedure request, CancellationToken cancel)
public async Task<int> Handle(DeleteEndpointAuthCommand request, CancellationToken cancel)
{
return await sender.Send(new DeleteObjectProcedure
{

View File

@@ -3,7 +3,7 @@ using ReC.Application.Common.Procedures.InsertProcedure;
namespace ReC.Application.EndpointAuth.Commands;
public record InsertEndpointAuthProcedure : IInsertProcedure
public record InsertEndpointAuthCommand : IInsertProcedure
{
public bool? Active { get; set; }
public string? Description { get; set; }
@@ -18,9 +18,9 @@ public record InsertEndpointAuthProcedure : IInsertProcedure
public string? Workstation { get; set; }
}
public class InsertEndpointAuthProcedureHandler(ISender sender) : IRequestHandler<InsertEndpointAuthProcedure, long>
public class InsertEndpointAuthProcedureHandler(ISender sender) : IRequestHandler<InsertEndpointAuthCommand, long>
{
public async Task<long> Handle(InsertEndpointAuthProcedure request, CancellationToken cancel)
public async Task<long> Handle(InsertEndpointAuthCommand request, CancellationToken cancel)
{
return await sender.Send(new InsertObjectProcedure
{

View File

@@ -4,16 +4,16 @@ using ReC.Application.Common.Procedures.UpdateProcedure.Dto;
namespace ReC.Application.EndpointAuth.Commands;
public record UpdateEndpointAuthProcedure : IUpdateProcedure<UpdateEndpointAuthDto>
public record UpdateEndpointAuthCommand : IUpdateProcedure<UpdateEndpointAuthDto>
{
public long Id { get; set; }
public UpdateEndpointAuthDto Data { get; set; } = null!;
}
public class UpdateEndpointAuthProcedureHandler(ISender sender) : IRequestHandler<UpdateEndpointAuthProcedure, int>
public class UpdateEndpointAuthProcedureHandler(ISender sender) : IRequestHandler<UpdateEndpointAuthCommand, int>
{
public async Task<int> Handle(UpdateEndpointAuthProcedure request, CancellationToken cancel)
public async Task<int> Handle(UpdateEndpointAuthCommand request, CancellationToken cancel)
{
return await sender.Send(new UpdateObjectProcedure
{

View File

@@ -3,7 +3,7 @@ using ReC.Application.Common.Procedures.DeleteProcedure;
namespace ReC.Application.EndpointParams.Commands;
public record DeleteEndpointParamsProcedure : IDeleteProcedure
public record DeleteEndpointParamsCommand : IDeleteProcedure
{
/// <summary>
/// Start GUID/ID (inclusive)
@@ -21,9 +21,9 @@ public record DeleteEndpointParamsProcedure : IDeleteProcedure
public bool Force { get; set; }
}
public class DeleteEndpointParamsProcedureHandler(ISender sender) : IRequestHandler<DeleteEndpointParamsProcedure, int>
public class DeleteEndpointParamsProcedureHandler(ISender sender) : IRequestHandler<DeleteEndpointParamsCommand, int>
{
public async Task<int> Handle(DeleteEndpointParamsProcedure request, CancellationToken cancel)
public async Task<int> Handle(DeleteEndpointParamsCommand request, CancellationToken cancel)
{
return await sender.Send(new DeleteObjectProcedure
{

View File

@@ -3,7 +3,7 @@ using ReC.Application.Common.Procedures.InsertProcedure;
namespace ReC.Application.EndpointParams.Commands;
public record InsertEndpointParamsProcedure : IInsertProcedure
public record InsertEndpointParamsCommand : IInsertProcedure
{
public bool? Active { get; set; }
public string? Description { get; set; }
@@ -13,9 +13,9 @@ public record InsertEndpointParamsProcedure : IInsertProcedure
public string? Value { get; set; }
}
public class InsertEndpointParamsProcedureHandler(ISender sender) : IRequestHandler<InsertEndpointParamsProcedure, long>
public class InsertEndpointParamsProcedureHandler(ISender sender) : IRequestHandler<InsertEndpointParamsCommand, long>
{
public async Task<long> Handle(InsertEndpointParamsProcedure request, CancellationToken cancel)
public async Task<long> Handle(InsertEndpointParamsCommand request, CancellationToken cancel)
{
return await sender.Send(new InsertObjectProcedure
{

View File

@@ -4,16 +4,16 @@ using ReC.Application.Common.Procedures.UpdateProcedure.Dto;
namespace ReC.Application.EndpointParams.Commands;
public record UpdateEndpointParamsProcedure : IUpdateProcedure<UpdateEndpointParamsDto>
public record UpdateEndpointParamsCommand : IUpdateProcedure<UpdateEndpointParamsDto>
{
public long Id { get; set; }
public UpdateEndpointParamsDto Data { get; set; } = null!;
}
public class UpdateEndpointParamsProcedureHandler(ISender sender) : IRequestHandler<UpdateEndpointParamsProcedure, int>
public class UpdateEndpointParamsProcedureHandler(ISender sender) : IRequestHandler<UpdateEndpointParamsCommand, int>
{
public async Task<int> Handle(UpdateEndpointParamsProcedure request, CancellationToken cancel)
public async Task<int> Handle(UpdateEndpointParamsCommand request, CancellationToken cancel)
{
return await sender.Send(new UpdateObjectProcedure
{

View File

@@ -3,7 +3,7 @@ using ReC.Application.Common.Procedures.DeleteProcedure;
namespace ReC.Application.Endpoints.Commands;
public record DeleteEndpointProcedure : IDeleteProcedure
public record DeleteEndpointCommand : IDeleteProcedure
{
/// <summary>
/// Start GUID/ID (inclusive)
@@ -21,9 +21,9 @@ public record DeleteEndpointProcedure : IDeleteProcedure
public bool Force { get; set; }
}
public class DeleteEndpointProcedureHandler(ISender sender) : IRequestHandler<DeleteEndpointProcedure, int>
public class DeleteEndpointProcedureHandler(ISender sender) : IRequestHandler<DeleteEndpointCommand, int>
{
public async Task<int> Handle(DeleteEndpointProcedure request, CancellationToken cancel)
public async Task<int> Handle(DeleteEndpointCommand request, CancellationToken cancel)
{
return await sender.Send(new DeleteObjectProcedure
{

View File

@@ -3,16 +3,16 @@ using ReC.Application.Common.Procedures.InsertProcedure;
namespace ReC.Application.Endpoints.Commands;
public record InsertEndpointProcedure : IInsertProcedure
public record InsertEndpointCommand : IInsertProcedure
{
public bool? Active { get; set; }
public string? Description { get; set; }
public string? Uri { get; set; }
}
public class InsertEndpointProcedureHandler(ISender sender) : IRequestHandler<InsertEndpointProcedure, long>
public class InsertEndpointProcedureHandler(ISender sender) : IRequestHandler<InsertEndpointCommand, long>
{
public async Task<long> Handle(InsertEndpointProcedure request, CancellationToken cancel)
public async Task<long> Handle(InsertEndpointCommand request, CancellationToken cancel)
{
return await sender.Send(new InsertObjectProcedure
{

View File

@@ -4,16 +4,16 @@ using ReC.Application.Common.Procedures.UpdateProcedure.Dto;
namespace ReC.Application.Endpoints.Commands;
public record UpdateEndpointProcedure : IUpdateProcedure<UpdateEndpointDto>
public record UpdateEndpointCommand : IUpdateProcedure<UpdateEndpointDto>
{
public long Id { get; set; }
public UpdateEndpointDto Data { get; set; } = null!;
}
public class UpdateEndpointProcedureHandler(ISender sender) : IRequestHandler<UpdateEndpointProcedure, int>
public class UpdateEndpointProcedureHandler(ISender sender) : IRequestHandler<UpdateEndpointCommand, int>
{
public async Task<int> Handle(UpdateEndpointProcedure request, CancellationToken cancel)
public async Task<int> Handle(UpdateEndpointCommand request, CancellationToken cancel)
{
return await sender.Send(new UpdateObjectProcedure
{

View File

@@ -3,7 +3,7 @@ using ReC.Application.Common.Procedures.DeleteProcedure;
namespace ReC.Application.Profile.Commands;
public record DeleteProfileProcedure : IDeleteProcedure
public record DeleteProfileCommand : IDeleteProcedure
{
/// <summary>
/// Start GUID/ID (inclusive)
@@ -21,9 +21,9 @@ public record DeleteProfileProcedure : IDeleteProcedure
public bool Force { get; set; }
}
public class DeleteProfileProcedureHandler(ISender sender) : IRequestHandler<DeleteProfileProcedure, int>
public class DeleteProfileProcedureHandler(ISender sender) : IRequestHandler<DeleteProfileCommand, int>
{
public async Task<int> Handle(DeleteProfileProcedure request, CancellationToken cancel)
public async Task<int> Handle(DeleteProfileCommand request, CancellationToken cancel)
{
return await sender.Send(new DeleteObjectProcedure
{

View File

@@ -3,7 +3,7 @@ using ReC.Application.Common.Procedures.InsertProcedure;
namespace ReC.Application.Profile.Commands;
public record InsertProfileProcedure : IInsertProcedure
public record InsertProfileCommand : IInsertProcedure
{
public bool? Active { get; set; }
public byte? TypeId { get; set; }
@@ -14,9 +14,9 @@ public record InsertProfileProcedure : IInsertProcedure
public short? LanguageId { get; set; }
}
public class InsertProfileProcedureHandler(ISender sender) : IRequestHandler<InsertProfileProcedure, long>
public class InsertProfileProcedureHandler(ISender sender) : IRequestHandler<InsertProfileCommand, long>
{
public async Task<long> Handle(InsertProfileProcedure request, CancellationToken cancel)
public async Task<long> Handle(InsertProfileCommand request, CancellationToken cancel)
{
return await sender.Send(new InsertObjectProcedure
{

View File

@@ -4,16 +4,16 @@ using ReC.Application.Common.Procedures.UpdateProcedure.Dto;
namespace ReC.Application.Profile.Commands;
public record UpdateProfileProcedure : IUpdateProcedure<UpdateProfileDto>
public record UpdateProfileCommand : IUpdateProcedure<UpdateProfileDto>
{
public long Id { get; set; }
public UpdateProfileDto Data { get; set; } = null!;
}
public class UpdateProfileProcedureHandler(ISender sender) : IRequestHandler<UpdateProfileProcedure, int>
public class UpdateProfileProcedureHandler(ISender sender) : IRequestHandler<UpdateProfileCommand, int>
{
public async Task<int> Handle(UpdateProfileProcedure request, CancellationToken cancel)
public async Task<int> Handle(UpdateProfileCommand request, CancellationToken cancel)
{
return await sender.Send(new UpdateObjectProcedure
{

View File

@@ -3,7 +3,7 @@ using ReC.Application.Common.Procedures.DeleteProcedure;
namespace ReC.Application.RecActions.Commands;
public record DeleteActionProcedure : IDeleteProcedure
public record DeleteActionCommand : IDeleteProcedure
{
/// <summary>
/// Start GUID/ID (inclusive)
@@ -21,9 +21,9 @@ public record DeleteActionProcedure : IDeleteProcedure
public bool Force { get; set; }
}
public class DeleteActionProcedureHandler(ISender sender) : IRequestHandler<DeleteActionProcedure, int>
public class DeleteActionProcedureHandler(ISender sender) : IRequestHandler<DeleteActionCommand, int>
{
public async Task<int> Handle(DeleteActionProcedure request, CancellationToken cancel)
public async Task<int> Handle(DeleteActionCommand request, CancellationToken cancel)
{
return await sender.Send(new DeleteObjectProcedure
{

View File

@@ -4,7 +4,7 @@ using ReC.Domain.Constants;
namespace ReC.Application.RecActions.Commands;
public record InsertActionProcedure : IInsertProcedure
public record InsertActionCommand : IInsertProcedure
{
public long? ProfileId { get; set; }
public bool? Active { get; set; }
@@ -21,9 +21,9 @@ public record InsertActionProcedure : IInsertProcedure
public byte? ErrorActionId { get; set; }
}
public class InsertActionProcedureHandler(ISender sender) : IRequestHandler<InsertActionProcedure, long>
public class InsertActionProcedureHandler(ISender sender) : IRequestHandler<InsertActionCommand, long>
{
public async Task<long> Handle(InsertActionProcedure request, CancellationToken cancel)
public async Task<long> Handle(InsertActionCommand request, CancellationToken cancel)
{
return await sender.Send(new InsertObjectProcedure
{

View File

@@ -24,15 +24,21 @@ public class InvokeRecActionViewsCommandHandler(ISender sender) : IRequestHandle
foreach (var action in actions)
{
var ok = await sender.Send(new InvokeRecActionViewCommand() { Action = action }, cancel);
if (!ok)
try
{
await sender.Send(new InvokeRecActionViewCommand() { Action = action }, cancel);
}
catch
{
switch (action.ErrorAction)
{
case ErrorAction.Continue:
break;
default:
return;
// Rethrow the exception to stop processing further actions
throw;
}
}
}
}
}

View File

@@ -1,12 +1,10 @@
using MediatR;
using MediatR;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Options;
using ReC.Application.Common;
using ReC.Application.Common.Constants;
using ReC.Application.Common.Dto;
using ReC.Application.Common.Exceptions;
using ReC.Application.Common.Options;
using ReC.Application.Common.Procedures.InsertProcedure;
using ReC.Application.Results.Commands;
using ReC.Domain.Constants;
using System.Net;
@@ -16,7 +14,7 @@ using System.Text.Json;
namespace ReC.Application.RecActions.Commands;
public record InvokeRecActionViewCommand : IRequest<bool>
public record InvokeRecActionViewCommand : IRequest
{
public RecActionViewDto Action { get; set; } = null!;
}
@@ -26,35 +24,33 @@ public class InvokeRecActionViewCommandHandler(
ISender sender,
IHttpClientFactory clientFactory,
IConfiguration? config = null
) : IRequestHandler<InvokeRecActionViewCommand, bool>
) : IRequestHandler<InvokeRecActionViewCommand>
{
private readonly RecActionOptions _options = options.Value;
public async Task<bool> Handle(InvokeRecActionViewCommand request, CancellationToken cancel)
public async Task Handle(InvokeRecActionViewCommand request, CancellationToken cancel)
{
var action = request.Action;
if (action.RestType is not RestType restType)
throw new DataIntegrityException(
$"Rec action could not be invoked because the RestType value is null. " +
$"ProfileId: {action.ProfileId}, " +
$"Id: {action.Id}"
);
using var httpReq = CreateHttpRequestMessage(restType, action.EndpointUri);
if (action.Body is not null)
httpReq.Content = new StringContent(action.Body);
if (action.Headers is not null)
foreach (var header in action.Headers)
httpReq.Headers.Add(header.Key, header.Value);
HttpClient? ntlmClient = null;
HttpClientHandler? ntlmHandler = null;
try
{
if (action.RestType is not RestType restType)
throw new DataIntegrityException(
$"Rec action could not be invoked because the RestType value is null. " +
$"ProfileId: {action.ProfileId}, " +
$"Id: {action.Id}"
);
using var httpReq = CreateHttpRequestMessage(restType, action.EndpointUri);
if (action.Body is not null)
httpReq.Content = new StringContent(action.Body);
if (action.Headers is not null)
foreach (var header in action.Headers)
httpReq.Headers.Add(header.Key, header.Value);
switch (action.EndpointAuthType)
{
case EndpointAuthType.NoAuth:
@@ -118,12 +114,12 @@ public class InvokeRecActionViewCommandHandler(
endpointAuthPassword,
action.EndpointAuthDomain);
var credentialCache = new CredentialCache { { httpReq.RequestUri!, "NTLM", credentials } };
ntlmHandler = new HttpClientHandler
var ntlmHandler = new HttpClientHandler
{
Credentials = credentialCache,
UseDefaultCredentials = false
};
ntlmClient = new HttpClient(ntlmHandler);
ntlmClient = new HttpClient(ntlmHandler, disposeHandler: true);
}
break;
@@ -141,26 +137,35 @@ public class InvokeRecActionViewCommandHandler(
);
}
using var http = ntlmClient ?? clientFactory.CreateClient(Http.ClientName);
var http = ntlmClient ?? clientFactory.CreateClient(Http.ClientName);
using var response = await http.SendAsync(httpReq, cancel);
var resBody = await response.Content.ReadAsStringAsync(cancel);
var resHeaders = response.Headers.ToDictionary();
var statusCode = (short)response.StatusCode;
await sender.Send(new InsertResultProcedure()
await sender.Send(new InsertResultCommand()
{
StatusId = statusCode,
ActionId = action.Id,
Header = JsonSerializer.Serialize(resHeaders, options: new() { WriteIndented = false }),
Body = resBody
}, cancel);
}
catch(Exception ex)
{
await sender.Send(new InsertResultCommand()
{
ActionId = action.Id,
Error = ex.ToString()
}, cancel);
return response.IsSuccessStatusCode;
if (action.ErrorAction == ErrorAction.Stop)
throw;
}
finally
{
ntlmHandler?.Dispose();
ntlmClient?.Dispose();
}
}

View File

@@ -4,16 +4,16 @@ using ReC.Application.Common.Procedures.UpdateProcedure.Dto;
namespace ReC.Application.RecActions.Commands;
public record UpdateActionProcedure : IUpdateProcedure<UpdateActionDto>
public record UpdateActionCommand : IUpdateProcedure<UpdateActionDto>
{
public long Id { get; set; }
public UpdateActionDto Data { get; set; } = null!;
}
public class UpdateActionProcedureHandler(ISender sender) : IRequestHandler<UpdateActionProcedure, int>
public class UpdateActionProcedureHandler(ISender sender) : IRequestHandler<UpdateActionCommand, int>
{
public async Task<int> Handle(UpdateActionProcedure request, CancellationToken cancel)
public async Task<int> Handle(UpdateActionCommand request, CancellationToken cancel)
{
return await sender.Send(new UpdateObjectProcedure
{

View File

@@ -3,7 +3,7 @@ using ReC.Application.Common.Procedures.DeleteProcedure;
namespace ReC.Application.Results.Commands;
public record DeleteResultProcedure : IDeleteProcedure
public record DeleteResultCommand : IDeleteProcedure
{
/// <summary>
/// Start GUID/ID (inclusive)
@@ -21,9 +21,9 @@ public record DeleteResultProcedure : IDeleteProcedure
public bool Force { get; set; }
}
public class DeleteResultProcedureHandler(ISender sender) : IRequestHandler<DeleteResultProcedure, int>
public class DeleteResultProcedureHandler(ISender sender) : IRequestHandler<DeleteResultCommand, int>
{
public async Task<int> Handle(DeleteResultProcedure request, CancellationToken cancel)
public async Task<int> Handle(DeleteResultCommand request, CancellationToken cancel)
{
return await sender.Send(new DeleteObjectProcedure
{

View File

@@ -3,7 +3,7 @@ using ReC.Application.Common.Procedures.InsertProcedure;
namespace ReC.Application.Results.Commands;
public record InsertResultProcedure : IInsertProcedure
public record InsertResultCommand : IInsertProcedure
{
public long? ActionId { get; set; }
public short? StatusId { get; set; }
@@ -13,9 +13,9 @@ public record InsertResultProcedure : IInsertProcedure
public string? Error { get; set; }
}
public class InsertResultProcedureHandler(ISender sender) : IRequestHandler<InsertResultProcedure, long>
public class InsertResultProcedureHandler(ISender sender) : IRequestHandler<InsertResultCommand, long>
{
public async Task<long> Handle(InsertResultProcedure request, CancellationToken cancel)
public async Task<long> Handle(InsertResultCommand request, CancellationToken cancel)
{
return await sender.Send(new InsertObjectProcedure
{

View File

@@ -4,16 +4,16 @@ using ReC.Application.Common.Procedures.UpdateProcedure.Dto;
namespace ReC.Application.Results.Commands;
public record UpdateResultProcedure : IUpdateProcedure<UpdateResultDto>
public record UpdateResultCommand : IUpdateProcedure<UpdateResultDto>
{
public long Id { get; set; }
public UpdateResultDto Data { get; set; } = null!;
}
public class UpdateResultProcedureHandler(ISender sender) : IRequestHandler<UpdateResultProcedure, int>
public class UpdateResultProcedureHandler(ISender sender) : IRequestHandler<UpdateResultCommand, int>
{
public async Task<int> Handle(UpdateResultProcedure request, CancellationToken cancel)
public async Task<int> Handle(UpdateResultCommand request, CancellationToken cancel)
{
return await sender.Send(new UpdateObjectProcedure
{

View File

@@ -23,7 +23,7 @@ public class EndpointAuthProcedureTests : RecApplicationTestBase
[Test]
public async Task InsertEndpointAuthProcedure_runs_via_mediator()
{
var procedure = new InsertEndpointAuthProcedure { Active = true, Description = "auth", TypeId = 1, ApiKey = "key", ApiValue = "value" };
var procedure = new InsertEndpointAuthCommand { Active = true, Description = "auth", TypeId = 1, ApiKey = "key", ApiValue = "value" };
var (sender, scope) = CreateScopedSender();
using var _ = scope;
@@ -35,7 +35,7 @@ public class EndpointAuthProcedureTests : RecApplicationTestBase
[Test]
public async Task UpdateEndpointAuthProcedure_runs_via_mediator()
{
var procedure = new UpdateEndpointAuthProcedure { Data = { Active = false, Description = "auth-update", TypeId = 2 }, Id = 15 };
var procedure = new UpdateEndpointAuthCommand { Data = { Active = false, Description = "auth-update", TypeId = 2 }, Id = 15 };
var (sender, scope) = CreateScopedSender();
using var _ = scope;
@@ -47,7 +47,7 @@ public class EndpointAuthProcedureTests : RecApplicationTestBase
[Test]
public async Task DeleteEndpointAuthProcedure_runs_via_mediator()
{
var procedure = new DeleteEndpointAuthProcedure { Start = 3, End = 4, Force = false };
var procedure = new DeleteEndpointAuthCommand { Start = 3, End = 4, Force = false };
var (sender, scope) = CreateScopedSender();
using var _ = scope;

View File

@@ -17,7 +17,7 @@ public class EndpointParamsProcedureTests : RecApplicationTestBase
[Test]
public async Task InsertEndpointParamsProcedure_runs_via_mediator()
{
var procedure = new InsertEndpointParamsProcedure { Active = true, Description = "param", GroupId = 1, Sequence = 1, Key = "k", Value = "v" };
var procedure = new InsertEndpointParamsCommand { Active = true, Description = "param", GroupId = 1, Sequence = 1, Key = "k", Value = "v" };
var (sender, scope) = CreateScopedSender();
using var _ = scope;
@@ -29,7 +29,7 @@ public class EndpointParamsProcedureTests : RecApplicationTestBase
[Test]
public async Task UpdateEndpointParamsProcedure_runs_via_mediator()
{
var procedure = new UpdateEndpointParamsProcedure { Data = { Active = false, Description = "param-update", GroupId = 2, Sequence = 2, Key = "k2", Value = "v2" }, Id = 25 };
var procedure = new UpdateEndpointParamsCommand { Data = { Active = false, Description = "param-update", GroupId = 2, Sequence = 2, Key = "k2", Value = "v2" }, Id = 25 };
var (sender, scope) = CreateScopedSender();
using var _ = scope;
@@ -41,7 +41,7 @@ public class EndpointParamsProcedureTests : RecApplicationTestBase
[Test]
public async Task DeleteEndpointParamsProcedure_runs_via_mediator()
{
var procedure = new DeleteEndpointParamsProcedure { Start = 5, End = 6, Force = true };
var procedure = new DeleteEndpointParamsCommand { Start = 5, End = 6, Force = true };
var (sender, scope) = CreateScopedSender();
using var _ = scope;

View File

@@ -23,7 +23,7 @@ public class EndpointProcedureTests : RecApplicationTestBase
[Test]
public async Task InsertEndpointProcedure_runs_via_mediator()
{
var procedure = new InsertEndpointProcedure { Active = true, Description = "desc", Uri = "http://example" };
var procedure = new InsertEndpointCommand { Active = true, Description = "desc", Uri = "http://example" };
var (sender, scope) = CreateScopedSender();
using var _ = scope;
@@ -35,7 +35,7 @@ public class EndpointProcedureTests : RecApplicationTestBase
[Test]
public async Task UpdateEndpointProcedure_runs_via_mediator()
{
var procedure = new UpdateEndpointProcedure { Data = { Active = false, Description = "updated", Uri = "http://updated" }, Id = 12 };
var procedure = new UpdateEndpointCommand { Data = { Active = false, Description = "updated", Uri = "http://updated" }, Id = 12 };
var (sender, scope) = CreateScopedSender();
using var _ = scope;
@@ -47,7 +47,7 @@ public class EndpointProcedureTests : RecApplicationTestBase
[Test]
public async Task DeleteEndpointProcedure_runs_via_mediator()
{
var procedure = new DeleteEndpointProcedure { Start = 1, End = 2, Force = true };
var procedure = new DeleteEndpointCommand { Start = 1, End = 2, Force = true };
var (sender, scope) = CreateScopedSender();
using var _ = scope;

View File

@@ -23,7 +23,7 @@ public class ProcedureExecutionTests : RecApplicationTestBase
[Test]
public async Task ExecuteInsertProcedure_runs_with_addedWho()
{
var procedure = new InsertProfileProcedure { Name = "name" };
var procedure = new InsertProfileCommand { Name = "name" };
var (sender, scope) = CreateScopedSender();
using var _ = scope;
@@ -35,7 +35,7 @@ public class ProcedureExecutionTests : RecApplicationTestBase
[Test]
public async Task ExecuteUpdateProcedure_runs_with_changedWho()
{
var procedure = new UpdateProfileProcedure { Data = { Name = "updated" }, Id = 123 };
var procedure = new UpdateProfileCommand { Data = { Name = "updated" }, Id = 123 };
var (sender, scope) = CreateScopedSender();
using var _ = scope;
@@ -47,7 +47,7 @@ public class ProcedureExecutionTests : RecApplicationTestBase
[Test]
public async Task ExecuteDeleteProcedure_runs()
{
var procedure = new DeleteProfileProcedure { Start = 1, End = 2, Force = true };
var procedure = new DeleteProfileCommand { Start = 1, End = 2, Force = true };
var (sender, scope) = CreateScopedSender();
using var _ = scope;

View File

@@ -23,7 +23,7 @@ public class ProfileProcedureTests : RecApplicationTestBase
[Test]
public async Task InsertProfileProcedure_runs_via_mediator()
{
var procedure = new InsertProfileProcedure { Active = true, TypeId = 1, Name = "name", Mandantor = "man" };
var procedure = new InsertProfileCommand { Active = true, TypeId = 1, Name = "name", Mandantor = "man" };
var (sender, scope) = CreateScopedSender();
using var _ = scope;
@@ -35,7 +35,7 @@ public class ProfileProcedureTests : RecApplicationTestBase
[Test]
public async Task UpdateProfileProcedure_runs_via_mediator()
{
var procedure = new UpdateProfileProcedure { Data = { Active = false, TypeId = 2, Name = "updated", Mandantor = "man2" }, Id = 45 };
var procedure = new UpdateProfileCommand { Data = { Active = false, TypeId = 2, Name = "updated", Mandantor = "man2" }, Id = 45 };
var (sender, scope) = CreateScopedSender();
using var _ = scope;
@@ -47,7 +47,7 @@ public class ProfileProcedureTests : RecApplicationTestBase
[Test]
public async Task DeleteProfileProcedure_runs_via_mediator()
{
var procedure = new DeleteProfileProcedure { Start = 9, End = 10, Force = false };
var procedure = new DeleteProfileCommand { Start = 9, End = 10, Force = false };
var (sender, scope) = CreateScopedSender();
using var _ = scope;

View File

@@ -25,7 +25,7 @@ public class RecActionProcedureTests : RecApplicationTestBase
{
try
{
var procedure = new InsertActionProcedure { ProfileId = 1, Active = true, Sequence = 1, EndpointId = 1 };
var procedure = new InsertActionCommand { ProfileId = 1, Active = true, Sequence = 1, EndpointId = 1 };
var (sender, scope) = CreateScopedSender();
using var _ = scope;
@@ -53,7 +53,7 @@ public class RecActionProcedureTests : RecApplicationTestBase
[Test]
public async Task UpdateActionProcedure_runs_via_mediator()
{
var procedure = new UpdateActionProcedure { Data = { ProfileId = 2, Active = false, Sequence = 2 }, Id = 35 };
var procedure = new UpdateActionCommand { Data = { ProfileId = 2, Active = false, Sequence = 2 }, Id = 35 };
var (sender, scope) = CreateScopedSender();
using var _ = scope;
@@ -65,7 +65,7 @@ public class RecActionProcedureTests : RecApplicationTestBase
[Test]
public async Task DeleteActionProcedure_runs_via_mediator()
{
var procedure = new DeleteActionProcedure { Start = 7, End = 8, Force = true };
var procedure = new DeleteActionCommand { Start = 7, End = 8, Force = true };
var (sender, scope) = CreateScopedSender();
using var _ = scope;

View File

@@ -23,7 +23,7 @@ public class ResultProcedureTests : RecApplicationTestBase
[Test]
public async Task InsertResultProcedure_runs_via_mediator()
{
var procedure = new InsertResultProcedure { ActionId = 1, StatusId = 200, Header = "h", Body = "b" };
var procedure = new InsertResultCommand { ActionId = 1, StatusId = 200, Header = "h", Body = "b" };
var (sender, scope) = CreateScopedSender();
using var _ = scope;
@@ -35,7 +35,7 @@ public class ResultProcedureTests : RecApplicationTestBase
[Test]
public async Task UpdateResultProcedure_runs_via_mediator()
{
var procedure = new UpdateResultProcedure { Data = { ActionId = 2, StatusId = 500, Header = "h2", Body = "b2" }, Id = 55 };
var procedure = new UpdateResultCommand { Data = { ActionId = 2, StatusId = 500, Header = "h2", Body = "b2" }, Id = 55 };
var (sender, scope) = CreateScopedSender();
using var _ = scope;
@@ -47,7 +47,7 @@ public class ResultProcedureTests : RecApplicationTestBase
[Test]
public async Task DeleteResultProcedure_runs_via_mediator()
{
var procedure = new DeleteResultProcedure { Start = 11, End = 12, Force = false };
var procedure = new DeleteResultCommand { Start = 11, End = 12, Force = false };
var (sender, scope) = CreateScopedSender();
using var _ = scope;