Refactor ErrorAction to use enum for type safety
Changed RecActionDto.ErrorAction from string to ErrorAction enum, updating all related logic to use enum values instead of strings. Added necessary using directives. This improves type safety, reduces risk of typos, and enhances maintainability.
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
namespace ReC.Application.Common.Dto;
|
||||
using ReC.Application.Common.Constants;
|
||||
using ReC.Domain.Constants;
|
||||
|
||||
namespace ReC.Application.Common.Dto;
|
||||
|
||||
public record RecActionDto
|
||||
{
|
||||
@@ -62,7 +65,7 @@ public record RecActionDto
|
||||
|
||||
public string? PostprocessingQuery { get; init; }
|
||||
|
||||
public string? ErrorAction { get; init; }
|
||||
public ErrorAction ErrorAction { get; init; }
|
||||
|
||||
public UriBuilder ToEndpointUriBuilder()
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using MediatR;
|
||||
using ReC.Application.RecActions.Queries;
|
||||
using ReC.Domain.Constants;
|
||||
|
||||
namespace ReC.Application.RecActions.Commands;
|
||||
|
||||
@@ -21,9 +22,9 @@ public class InvokeRecActionsCommandHandler(ISender sender) : IRequestHandler<In
|
||||
{
|
||||
var ok = await sender.Send(action.ToInvokeCommand(), cancel);
|
||||
if (!ok)
|
||||
switch (action.ErrorAction?.ToLowerInvariant())
|
||||
switch (action.ErrorAction)
|
||||
{
|
||||
case "continue":
|
||||
case ErrorAction.Continue:
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user