From 9b3bb925f99c42bc0f2530bfb3b4597b8630989e Mon Sep 17 00:00:00 2001 From: TekH Date: Wed, 17 Dec 2025 09:35:24 +0100 Subject: [PATCH] Refactor ResultType enum location and naming for clarity Move ResultType enum to ReC.API.Models/ResultType.cs and update its values from Header/Body to OnlyHeader/OnlyBody for improved clarity. Update all controller usages and documentation to reflect these changes. --- src/ReC.API/Controllers/OutResController.cs | 28 ++++--------------- .../Controllers/ResultViewController.cs | 5 ++-- src/ReC.API/Models/ResultType.cs | 17 +++++++++++ 3 files changed, 25 insertions(+), 25 deletions(-) create mode 100644 src/ReC.API/Models/ResultType.cs diff --git a/src/ReC.API/Controllers/OutResController.cs b/src/ReC.API/Controllers/OutResController.cs index 1c90266..0a6390f 100644 --- a/src/ReC.API/Controllers/OutResController.cs +++ b/src/ReC.API/Controllers/OutResController.cs @@ -1,6 +1,7 @@ using MediatR; using Microsoft.AspNetCore.Mvc; using ReC.API.Extensions; +using ReC.API.Models; using ReC.Application.OutResults.Commands; using ReC.Application.OutResults.Queries; @@ -38,7 +39,7 @@ public class OutResController(IMediator mediator, IConfiguration config) : Contr /// /// The ID of the action to retrieve the result for. /// A token to cancel the operation. - /// Specifies which part of the result to return (Full, Header, or Body). + /// Specifies which part of the result to return (Full, OnlyHeader, or OnlyBody). /// The requested output result or a part of it (header/body). [HttpGet("fake/{actionId}")] [ProducesResponseType(StatusCodes.Status200OK)] @@ -52,8 +53,8 @@ public class OutResController(IMediator mediator, IConfiguration config) : Contr return resultType switch { - ResultType.Body => res.Body is null ? NotFound() : Ok(res.Body.JsonToDynamic()), - ResultType.Header => res.Header is null ? NotFound() : Ok(res.Header.JsonToDynamic()), + ResultType.OnlyBody => res.Body is null ? NotFound() : Ok(res.Body.JsonToDynamic()), + ResultType.OnlyHeader => res.Header is null ? NotFound() : Ok(res.Header.JsonToDynamic()), _ => Ok(res), }; } @@ -85,23 +86,4 @@ public class OutResController(IMediator mediator, IConfiguration config) : Contr await mediator.Send(new DeleteOutResCommand() { ProfileId = config.GetFakeProfileId() }, cancel); return NoContent(); } -} - -/// -/// Defines the type of result to be returned from an output result query. -/// -public enum ResultType -{ - /// - /// Return the full result object. - /// - Full, - /// - /// Return only the header part of the result. - /// - Header, - /// - /// Return only the body part of the result. - /// - Body -} +} \ No newline at end of file diff --git a/src/ReC.API/Controllers/ResultViewController.cs b/src/ReC.API/Controllers/ResultViewController.cs index b28a570..84cc4e9 100644 --- a/src/ReC.API/Controllers/ResultViewController.cs +++ b/src/ReC.API/Controllers/ResultViewController.cs @@ -1,6 +1,7 @@ using MediatR; using Microsoft.AspNetCore.Mvc; using ReC.API.Extensions; +using ReC.API.Models; using ReC.Application.ResultViews.Queries; namespace ReC.API.Controllers; @@ -32,8 +33,8 @@ public class ResultViewController(IMediator mediator, IConfiguration config) : C return resultType switch { - ResultType.Body => res.Body is null ? NotFound() : Ok(res.Body.JsonToDynamic()), - ResultType.Header => res.Header is null ? NotFound() : Ok(res.Header.JsonToDynamic()), + ResultType.OnlyBody => res.Body is null ? NotFound() : Ok(res.Body.JsonToDynamic()), + ResultType.OnlyHeader => res.Header is null ? NotFound() : Ok(res.Header.JsonToDynamic()), _ => Ok(res), }; } diff --git a/src/ReC.API/Models/ResultType.cs b/src/ReC.API/Models/ResultType.cs new file mode 100644 index 0000000..15751c9 --- /dev/null +++ b/src/ReC.API/Models/ResultType.cs @@ -0,0 +1,17 @@ +namespace ReC.API.Models; + +public enum ResultType +{ + /// + /// Return the full result object. + /// + Full, + /// + /// Return only the header part of the result. + /// + OnlyHeader, + /// + /// Return only the body part of the result. + /// + OnlyBody +} \ No newline at end of file