Require non-null References for batch rec action invoke
Enforce non-nullable References in RecActionController and InvokeBatchRecActionViewsCommand. Update tests to always provide References and add missing using directive. Improves type safety and ensures consistent reference handling.
This commit is contained in:
@@ -19,7 +19,7 @@ public class RecActionController(IMediator mediator) : ControllerBase
|
|||||||
/// <returns>An HTTP 202 Accepted response indicating the process has been started.</returns>
|
/// <returns>An HTTP 202 Accepted response indicating the process has been started.</returns>
|
||||||
[HttpPost("invoke/{profileId}")]
|
[HttpPost("invoke/{profileId}")]
|
||||||
[ProducesResponseType(StatusCodes.Status202Accepted)]
|
[ProducesResponseType(StatusCodes.Status202Accepted)]
|
||||||
public async Task<IActionResult> Invoke([FromRoute] long profileId, [FromBody] InvokeReferences? references = null, CancellationToken cancel = default)
|
public async Task<IActionResult> Invoke([FromRoute] long profileId, [FromBody] InvokeReferences references, CancellationToken cancel = default)
|
||||||
{
|
{
|
||||||
await mediator.Send(new InvokeBatchRecActionViewsCommand
|
await mediator.Send(new InvokeBatchRecActionViewsCommand
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ namespace ReC.Application.RecActions.Commands;
|
|||||||
public record InvokeBatchRecActionViewsCommand : IRequest
|
public record InvokeBatchRecActionViewsCommand : IRequest
|
||||||
{
|
{
|
||||||
public long ProfileId { get; init; }
|
public long ProfileId { get; init; }
|
||||||
public InvokeReferences? References { get; init; }
|
public required InvokeReferences References { get; init; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class InvokeRecActionViewsCommandHandler(ISender sender, ILogger<InvokeRecActionViewsCommandHandler>? logger = null) : IRequestHandler<InvokeBatchRecActionViewsCommand>
|
public class InvokeRecActionViewsCommandHandler(ISender sender, ILogger<InvokeRecActionViewsCommandHandler>? logger = null) : IRequestHandler<InvokeBatchRecActionViewsCommand>
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using NUnit.Framework;
|
|||||||
using ReC.Application.Common.Procedures.DeleteProcedure;
|
using ReC.Application.Common.Procedures.DeleteProcedure;
|
||||||
using ReC.Application.Common.Procedures.InsertProcedure;
|
using ReC.Application.Common.Procedures.InsertProcedure;
|
||||||
using ReC.Application.Common.Procedures.UpdateProcedure;
|
using ReC.Application.Common.Procedures.UpdateProcedure;
|
||||||
|
using ReC.Application.RecActions.Commands;
|
||||||
using ReC.Application.Results.Commands;
|
using ReC.Application.Results.Commands;
|
||||||
using ReC.Domain.Constants;
|
using ReC.Domain.Constants;
|
||||||
using ReC.Tests.Application;
|
using ReC.Tests.Application;
|
||||||
@@ -25,7 +26,7 @@ public class ResultProcedureTests : RecApplicationTestBase
|
|||||||
[Test]
|
[Test]
|
||||||
public async Task InsertResultProcedure_runs_via_mediator()
|
public async Task InsertResultProcedure_runs_via_mediator()
|
||||||
{
|
{
|
||||||
var procedure = new InsertResultCommand { ActionId = 1, Status = HttpStatusCode.OK.ToRecStatus(), Header = "h", Body = "b", Info = 200, Type = Domain.Constants.ResultType.Main };
|
var procedure = new InsertResultCommand { ActionId = 1, Status = HttpStatusCode.OK.ToRecStatus(), Header = "h", Body = "b", Info = 200, Type = ResultType.Main, References = new () { BatchId = DateTime.Now.ToString() } };
|
||||||
|
|
||||||
var (sender, scope) = CreateScopedSender();
|
var (sender, scope) = CreateScopedSender();
|
||||||
using var _ = scope;
|
using var _ = scope;
|
||||||
|
|||||||
Reference in New Issue
Block a user