From acff0aca8902b742ed39d60461f15346132b0866 Mon Sep 17 00:00:00 2001 From: TekH Date: Mon, 30 Mar 2026 11:35:22 +0200 Subject: [PATCH] Rename Status enum to RecStatus across the codebase Refactored all usages of the Status enum to RecStatus to improve clarity and prevent naming conflicts with other status enums (e.g., HTTP status codes). Updated command handlers, behaviors, data models, and extension methods to use RecStatus, and adjusted related serialization logic accordingly. This makes the domain-specific status handling more explicit and maintainable. --- .../Behaviors/InvokeAction/PostprocessingBehavior.cs | 4 ++-- .../Behaviors/InvokeAction/PreprocessingBehavior.cs | 4 ++-- .../RecActions/Commands/InvokeRecActionViewCommand.cs | 2 +- .../Results/Commands/InsertResultCommand.cs | 2 +- src/ReC.Domain/Constants/{Status.cs => RecStatus.cs} | 2 +- src/ReC.Domain/Constants/StatusExtensions.cs | 10 +++++----- src/ReC.Domain/Views/ResultView.cs | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) rename src/ReC.Domain/Constants/{Status.cs => RecStatus.cs} (99%) diff --git a/src/ReC.Application/Common/Behaviors/InvokeAction/PostprocessingBehavior.cs b/src/ReC.Application/Common/Behaviors/InvokeAction/PostprocessingBehavior.cs index 68e60c1..9fb3004 100644 --- a/src/ReC.Application/Common/Behaviors/InvokeAction/PostprocessingBehavior.cs +++ b/src/ReC.Application/Common/Behaviors/InvokeAction/PostprocessingBehavior.cs @@ -23,7 +23,7 @@ public class PostprocessingBehavior(IRecDbContext context, ISender sender) : IPi await sender.Send(new InsertResultCommand() { - Status = Status.QuerySuccess, + Status = RecStatus.QuerySuccess, ActionId = request.Action.Id, Info = info, Type = ResultType.Post @@ -36,7 +36,7 @@ public class PostprocessingBehavior(IRecDbContext context, ISender sender) : IPi await sender.Send(new InsertResultCommand() { - Status = Status.QueryFailed, + Status = RecStatus.QueryFailed, ActionId = request.Action.Id, Error = error, Type = ResultType.Post diff --git a/src/ReC.Application/Common/Behaviors/InvokeAction/PreprocessingBehavior.cs b/src/ReC.Application/Common/Behaviors/InvokeAction/PreprocessingBehavior.cs index c857ff9..e5063c7 100644 --- a/src/ReC.Application/Common/Behaviors/InvokeAction/PreprocessingBehavior.cs +++ b/src/ReC.Application/Common/Behaviors/InvokeAction/PreprocessingBehavior.cs @@ -20,7 +20,7 @@ public class PreprocessingBehavior(IRecDbContext context, ISender sender) : IPip await sender.Send(new InsertResultCommand() { - Status = Status.QuerySuccess, + Status = RecStatus.QuerySuccess, ActionId = request.Action.Id, Info = JsonSerializer.Serialize(result), Type = ResultType.Pre @@ -31,7 +31,7 @@ public class PreprocessingBehavior(IRecDbContext context, ISender sender) : IPip { await sender.Send(new InsertResultCommand() { - Status = Status.QueryFailed, + Status = RecStatus.QueryFailed, ActionId = request.Action.Id, Error = ex.ToString(), Type = ResultType.Pre diff --git a/src/ReC.Application/RecActions/Commands/InvokeRecActionViewCommand.cs b/src/ReC.Application/RecActions/Commands/InvokeRecActionViewCommand.cs index 8d7851d..9b7c93e 100644 --- a/src/ReC.Application/RecActions/Commands/InvokeRecActionViewCommand.cs +++ b/src/ReC.Application/RecActions/Commands/InvokeRecActionViewCommand.cs @@ -157,7 +157,7 @@ public class InvokeRecActionViewCommandHandler( { await sender.Send(new InsertResultCommand() { - Status = Status.QueryFailed, + Status = RecStatus.QueryFailed, ActionId = action.Id, Error = ex.ToString(), Type = ResultType.Main diff --git a/src/ReC.Application/Results/Commands/InsertResultCommand.cs b/src/ReC.Application/Results/Commands/InsertResultCommand.cs index 8d25e08..98f1f4b 100644 --- a/src/ReC.Application/Results/Commands/InsertResultCommand.cs +++ b/src/ReC.Application/Results/Commands/InsertResultCommand.cs @@ -7,7 +7,7 @@ namespace ReC.Application.Results.Commands; public record InsertResultCommand : IInsertProcedure { public long? ActionId { get; set; } - public required Status Status { get; set; } + public required RecStatus Status { get; set; } public string? Header { get; set; } public string? Body { get; set; } public string? Info { get; set; } diff --git a/src/ReC.Domain/Constants/Status.cs b/src/ReC.Domain/Constants/RecStatus.cs similarity index 99% rename from src/ReC.Domain/Constants/Status.cs rename to src/ReC.Domain/Constants/RecStatus.cs index 9af4ced..72b4bff 100644 --- a/src/ReC.Domain/Constants/Status.cs +++ b/src/ReC.Domain/Constants/RecStatus.cs @@ -11,7 +11,7 @@ namespace ReC.Domain.Constants; /// /// /// -public enum Status : short +public enum RecStatus : short { /// /// Indicates that a SQL query executed successfully (value 0). diff --git a/src/ReC.Domain/Constants/StatusExtensions.cs b/src/ReC.Domain/Constants/StatusExtensions.cs index 94aa09a..1cf7a3d 100644 --- a/src/ReC.Domain/Constants/StatusExtensions.cs +++ b/src/ReC.Domain/Constants/StatusExtensions.cs @@ -4,7 +4,7 @@ namespace ReC.Domain.Constants; public static class StatusExtensions { - public static HttpStatusCode? ToHttpStatusCode(this Status status) + public static HttpStatusCode? ToHttpStatusCode(this RecStatus status) { int code = (int)status; @@ -22,13 +22,13 @@ public static class StatusExtensions return value >= 200 && value <= 299; } - public static bool IsSuccess(this Status status) + public static bool IsSuccess(this RecStatus status) => status switch { - Status.QuerySuccess => true, - Status.QueryFailed => false, + RecStatus.QuerySuccess => true, + RecStatus.QueryFailed => false, _ => status.ToHttpStatusCode() is HttpStatusCode httpStatus && httpStatus.IsSuccess() }; - public static Status ToStatus(this HttpStatusCode code) => (Status)(short)code; + public static RecStatus ToStatus(this HttpStatusCode code) => (RecStatus)(short)code; } \ No newline at end of file diff --git a/src/ReC.Domain/Views/ResultView.cs b/src/ReC.Domain/Views/ResultView.cs index 1c5bf96..677d0d0 100644 --- a/src/ReC.Domain/Views/ResultView.cs +++ b/src/ReC.Domain/Views/ResultView.cs @@ -25,7 +25,7 @@ public class ResultView public string? ProfileName { get; set; } [Column("STATUS_ID")] - public Status Status { get; set; } + public RecStatus Status { get; set; } [Column("STATUS")] public string? StatusName { get; set; }