diff --git a/src/ReC.API/ConfigExtensions.cs b/src/ReC.API/ConfigExtensions.cs new file mode 100644 index 0000000..aeb9345 --- /dev/null +++ b/src/ReC.API/ConfigExtensions.cs @@ -0,0 +1,6 @@ +namespace ReC.API; + +public static class ConfigurationExtensions +{ + public static int GetFakeProfileId(this IConfiguration config) => config.GetValue("FakeProfileId", 2); +} diff --git a/src/ReC.API/Controllers/OutResController.cs b/src/ReC.API/Controllers/OutResController.cs index a5fc458..70fb319 100644 --- a/src/ReC.API/Controllers/OutResController.cs +++ b/src/ReC.API/Controllers/OutResController.cs @@ -6,8 +6,14 @@ namespace ReC.API.Controllers; [Route("api/[controller]")] [ApiController] -public class OutResController(IMediator mediator) : ControllerBase +public class OutResController(IMediator mediator, IConfiguration config) : ControllerBase { [HttpGet] public async Task Get([FromQuery] ReadOutResQuery query) => Ok(await mediator.Send(query)); + + [HttpGet("fake")] + public async Task Get() => Ok(await mediator.Send(new ReadOutResQuery() + { + ProfileId = config.GetFakeProfileId() + })); } diff --git a/src/ReC.API/Controllers/RecActionController.cs b/src/ReC.API/Controllers/RecActionController.cs index 4783001..49f1bc4 100644 --- a/src/ReC.API/Controllers/RecActionController.cs +++ b/src/ReC.API/Controllers/RecActionController.cs @@ -9,10 +9,8 @@ namespace ReC.API.Controllers; [Route("api/[controller]")] [ApiController] -public class RecActionController(IMediator mediator) : ControllerBase +public class RecActionController(IMediator mediator, IConfiguration config) : ControllerBase { - private const long FakeProfileId = 2; - [HttpPost("invoke/{profileId}")] public async Task Invoke([FromRoute] int profileId, CancellationToken cancel) { @@ -23,7 +21,7 @@ public class RecActionController(IMediator mediator) : ControllerBase [HttpPost("invoke/fake")] public async Task Invoke(CancellationToken cancel) { - await mediator.InvokeBatchRecAction(FakeProfileId, cancel); + await mediator.InvokeBatchRecAction(config.GetFakeProfileId(), cancel); return Accepted(); } @@ -37,7 +35,7 @@ public class RecActionController(IMediator mediator) : ControllerBase [HttpGet("fake")] public async Task Get(CancellationToken cancel) => Ok(await mediator.Send(new ReadRecActionQuery() { - ProfileId = FakeProfileId + ProfileId = config.GetFakeProfileId() }, cancel)); [HttpPost] @@ -64,7 +62,7 @@ public class RecActionController(IMediator mediator) : ControllerBase await mediator.Send(new CreateRecActionCommand() { - ProfileId = FakeProfileId, + ProfileId = config.GetFakeProfileId(), EndpointUri = endpointUri, Type = type, BodyQuery = $@"SELECT '{bodyJson ?? "NULL"}' AS REQUEST_BODY;", @@ -81,7 +79,7 @@ public class RecActionController(IMediator mediator) : ControllerBase { await mediator.Send(new DeleteRecActionsCommand() { - ProfileId = FakeProfileId + ProfileId = config.GetFakeProfileId() }, cancel); return NoContent(); @@ -92,7 +90,7 @@ public class RecActionController(IMediator mediator) : ControllerBase { await mediator.Send(new DeleteRecActionsCommand() { - ProfileId = FakeProfileId + ProfileId = config.GetFakeProfileId() }, cancel); return NoContent(); diff --git a/src/ReC.API/appsettings.json b/src/ReC.API/appsettings.json index d120eff..bfd818e 100644 --- a/src/ReC.API/appsettings.json +++ b/src/ReC.API/appsettings.json @@ -13,5 +13,6 @@ "RecAction": { "MaxConcurrentInvocations": 5 }, - "AddedWho": "ReC.API" + "AddedWho": "ReC.API", + "FakeProfileId": 2 } \ No newline at end of file