using MediatR; using Microsoft.AspNetCore.Mvc; using ReC.Application.Profile.Commands; using ReC.Application.Profile.Queries; namespace ReC.API.Controllers; [Route("api/[controller]")] [ApiController] public class ProfileController(IMediator mediator) : ControllerBase { [HttpGet] public async Task Get([FromQuery] ReadProfileViewQuery query, CancellationToken cancel) { return Ok(await mediator.Send(query, cancel)); } /// /// Inserts a profile via the PROFILE insert procedure. /// /// InsertProfileProcedure payload. /// A token to cancel the operation. /// The created profile identifier. [HttpPost] [ProducesResponseType(StatusCodes.Status201Created)] public async Task Post([FromBody] InsertProfileCommand procedure, CancellationToken cancel) { var id = await mediator.Send(procedure, cancel); return CreatedAtAction(nameof(Get), new { id }, id); } /// /// Updates a profile via the PROFILE update procedure. /// /// UpdateProfileProcedure payload. /// A token to cancel the operation. /// No content on success. [HttpPut] [ProducesResponseType(StatusCodes.Status204NoContent)] public async Task Put([FromBody] UpdateProfileCommand procedure, CancellationToken cancel) { await mediator.Send(procedure, cancel); return NoContent(); } /// /// Deletes profile records via the PROFILE delete procedure for the specified id range. /// /// DeleteProfileProcedure payload (Start, End, Force). /// A token to cancel the operation. /// No content on success. [HttpDelete] [ProducesResponseType(StatusCodes.Status204NoContent)] public async Task Delete([FromBody] DeleteProfileCommand procedure, CancellationToken cancel) { await mediator.Send(procedure, cancel); return NoContent(); } }