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.
This commit is contained in:
2025-12-17 09:35:24 +01:00
parent a92d57d9cf
commit 9b3bb925f9
3 changed files with 25 additions and 25 deletions

View File

@@ -1,6 +1,7 @@
using MediatR; using MediatR;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using ReC.API.Extensions; using ReC.API.Extensions;
using ReC.API.Models;
using ReC.Application.OutResults.Commands; using ReC.Application.OutResults.Commands;
using ReC.Application.OutResults.Queries; using ReC.Application.OutResults.Queries;
@@ -38,7 +39,7 @@ public class OutResController(IMediator mediator, IConfiguration config) : Contr
/// </summary> /// </summary>
/// <param name="actionId">The ID of the action to retrieve the result for.</param> /// <param name="actionId">The ID of the action to retrieve the result for.</param>
/// <param name="cancel">A token to cancel the operation.</param> /// <param name="cancel">A token to cancel the operation.</param>
/// <param name="resultType">Specifies which part of the result to return (Full, Header, or Body).</param> /// <param name="resultType">Specifies which part of the result to return (Full, OnlyHeader, or OnlyBody).</param>
/// <returns>The requested output result or a part of it (header/body).</returns> /// <returns>The requested output result or a part of it (header/body).</returns>
[HttpGet("fake/{actionId}")] [HttpGet("fake/{actionId}")]
[ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status200OK)]
@@ -52,8 +53,8 @@ public class OutResController(IMediator mediator, IConfiguration config) : Contr
return resultType switch return resultType switch
{ {
ResultType.Body => res.Body is null ? NotFound() : Ok(res.Body.JsonToDynamic()), ResultType.OnlyBody => res.Body is null ? NotFound() : Ok(res.Body.JsonToDynamic()),
ResultType.Header => res.Header is null ? NotFound() : Ok(res.Header.JsonToDynamic()), ResultType.OnlyHeader => res.Header is null ? NotFound() : Ok(res.Header.JsonToDynamic()),
_ => Ok(res), _ => Ok(res),
}; };
} }
@@ -85,23 +86,4 @@ public class OutResController(IMediator mediator, IConfiguration config) : Contr
await mediator.Send(new DeleteOutResCommand() { ProfileId = config.GetFakeProfileId() }, cancel); await mediator.Send(new DeleteOutResCommand() { ProfileId = config.GetFakeProfileId() }, cancel);
return NoContent(); return NoContent();
} }
} }
/// <summary>
/// Defines the type of result to be returned from an output result query.
/// </summary>
public enum ResultType
{
/// <summary>
/// Return the full result object.
/// </summary>
Full,
/// <summary>
/// Return only the header part of the result.
/// </summary>
Header,
/// <summary>
/// Return only the body part of the result.
/// </summary>
Body
}

View File

@@ -1,6 +1,7 @@
using MediatR; using MediatR;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using ReC.API.Extensions; using ReC.API.Extensions;
using ReC.API.Models;
using ReC.Application.ResultViews.Queries; using ReC.Application.ResultViews.Queries;
namespace ReC.API.Controllers; namespace ReC.API.Controllers;
@@ -32,8 +33,8 @@ public class ResultViewController(IMediator mediator, IConfiguration config) : C
return resultType switch return resultType switch
{ {
ResultType.Body => res.Body is null ? NotFound() : Ok(res.Body.JsonToDynamic()), ResultType.OnlyBody => res.Body is null ? NotFound() : Ok(res.Body.JsonToDynamic()),
ResultType.Header => res.Header is null ? NotFound() : Ok(res.Header.JsonToDynamic()), ResultType.OnlyHeader => res.Header is null ? NotFound() : Ok(res.Header.JsonToDynamic()),
_ => Ok(res), _ => Ok(res),
}; };
} }

View File

@@ -0,0 +1,17 @@
namespace ReC.API.Models;
public enum ResultType
{
/// <summary>
/// Return the full result object.
/// </summary>
Full,
/// <summary>
/// Return only the header part of the result.
/// </summary>
OnlyHeader,
/// <summary>
/// Return only the body part of the result.
/// </summary>
OnlyBody
}