using MediatR; using Microsoft.AspNetCore.Mvc; using ReC.Application.Common.Procedures.UpdateProcedure.Dto; using ReC.Application.EndpointAuth.Commands; namespace ReC.API.Controllers; [Route("api/[controller]")] [ApiController] public class EndpointAuthController(IMediator mediator) : ControllerBase { /// /// Inserts an endpoint authentication record via the ENDPOINT_AUTH insert procedure. /// /// InsertEndpointAuthProcedure payload. /// A token to cancel the operation. /// The created ENDPOINT_AUTH identifier. [HttpPost] [ProducesResponseType(StatusCodes.Status201Created)] public async Task Post([FromBody] InsertEndpointAuthCommand procedure, CancellationToken cancel) { var id = await mediator.Send(procedure, cancel); return StatusCode(StatusCodes.Status201Created, id); } /// /// Updates an endpoint authentication record via the ENDPOINT_AUTH update procedure. /// /// The identifier of the ENDPOINT_AUTH record to update. /// UpdateEndpointAuthProcedure 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] UpdateEndpointAuthDto data, CancellationToken cancel) { await mediator.Send(new UpdateEndpointAuthCommand() { Id = id, Data = data}, cancel); return NoContent(); } /// /// Deletes endpoint authentication records via the ENDPOINT_AUTH delete procedure for the specified id range. /// /// DeleteEndpointAuthProcedure payload (Start, End, Force). /// A token to cancel the operation. /// No content on success. [HttpDelete] [ProducesResponseType(StatusCodes.Status204NoContent)] public async Task Delete([FromQuery] DeleteEndpointAuthCommand command, CancellationToken cancel) { await mediator.Send(command, cancel); return NoContent(); } }