using MediatR; using Microsoft.AspNetCore.Mvc; using ReC.Application.Common.Procedures.UpdateProcedure.Dto; using ReC.Application.EndpointParams.Commands; namespace ReC.API.Controllers; [Route("api/[controller]")] [ApiController] public class EndpointParamsController(IMediator mediator) : ControllerBase { /// /// Inserts endpoint parameter records via the ENDPOINT_PARAMS insert procedure. /// /// InsertEndpointParamsProcedure payload. /// A token to cancel the operation. /// The created ENDPOINT_PARAMS identifier. [HttpPost] [ProducesResponseType(StatusCodes.Status201Created)] public async Task Post([FromBody] InsertEndpointParamsCommand procedure, CancellationToken cancel) { var id = await mediator.Send(procedure, cancel); return StatusCode(StatusCodes.Status201Created, id); } /// /// Updates endpoint parameter records via the ENDPOINT_PARAMS update procedure. /// /// The identifier of the ENDPOINT_PARAMS record to update. /// UpdateEndpointParamsProcedure payload. /// A token to cancel the operation. /// No content on success. [HttpPut("{id:long}")] [ProducesResponseType(StatusCodes.Status204NoContent)] public async Task Put([FromRoute] long id, [FromBody] UpdateEndpointParamsDto data, CancellationToken cancel) { await mediator.Send(new UpdateEndpointParamsCommand() { Id = id, Data = data }, cancel); return NoContent(); } /// /// Deletes endpoint parameter records via the ENDPOINT_PARAMS delete procedure for the specified id range. /// /// DeleteEndpointParamsProcedure payload (Start, End, Force). /// A token to cancel the operation. /// No content on success. [HttpDelete] [ProducesResponseType(StatusCodes.Status204NoContent)] public async Task Delete([FromQuery] DeleteEndpointParamsCommand command, CancellationToken cancel) { await mediator.Send(command, cancel); return NoContent(); } }