diff --git a/src/ReC.API/Controllers/OutResController.cs b/src/ReC.API/Controllers/OutResController.cs index 70fb319..a7594a1 100644 --- a/src/ReC.API/Controllers/OutResController.cs +++ b/src/ReC.API/Controllers/OutResController.cs @@ -1,6 +1,9 @@ using MediatR; using Microsoft.AspNetCore.Mvc; +using ReC.API.Models; using ReC.Application.OutResults.Queries; +using System.Net.Mime; +using System.Text.Json; namespace ReC.API.Controllers; @@ -16,4 +19,31 @@ public class OutResController(IMediator mediator, IConfiguration config) : Contr { ProfileId = config.GetFakeProfileId() })); + + [HttpGet("fake/{actionId}")] + public async Task Get([FromRoute] long actionId, ResultType resultType = ResultType.Full) + { + var res = (await mediator.Send(new ReadOutResQuery() + { + ProfileId = config.GetFakeProfileId(), + ActionId = actionId + })).First(); + + if (resultType is not ResultType.Full) + HttpContext.Response.ContentType = MediaTypeNames.Application.Json; + + return resultType switch + { + ResultType.Body => res.Body is null ? Ok(new object { }) : Ok(JsonSerializer.Deserialize(res.Body)), + ResultType.Header => res.Header is null ? Ok(new object { }) : Ok(JsonSerializer.Deserialize(res.Header)), + _ => Ok(res), + }; + } +} + +public enum ResultType +{ + Full, + Header, + Body }