Files
ReC/src/ReC.API/Controllers/ProfileController.cs
TekH de503cac5b Rename Profile*Procedure types to Profile*Command for clarity
Renamed InsertProfileProcedure, UpdateProfileProcedure, and DeleteProfileProcedure (and their handlers) to use the "Command" suffix for consistency. Updated all usages in controllers, handlers, and tests. No logic changes; only type names were updated for improved clarity.
2026-03-24 11:39:04 +01:00

59 lines
2.2 KiB
C#

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<IActionResult> Get([FromQuery] ReadProfileViewQuery query, CancellationToken cancel)
{
return Ok(await mediator.Send(query, cancel));
}
/// <summary>
/// Inserts a profile via the PROFILE insert procedure.
/// </summary>
/// <param name="procedure">InsertProfileProcedure payload.</param>
/// <param name="cancel">A token to cancel the operation.</param>
/// <returns>The created profile identifier.</returns>
[HttpPost]
[ProducesResponseType(StatusCodes.Status201Created)]
public async Task<IActionResult> Post([FromBody] InsertProfileCommand procedure, CancellationToken cancel)
{
var id = await mediator.Send(procedure, cancel);
return CreatedAtAction(nameof(Get), new { id }, id);
}
/// <summary>
/// Updates a profile via the PROFILE update procedure.
/// </summary>
/// <param name="procedure">UpdateProfileProcedure payload.</param>
/// <param name="cancel">A token to cancel the operation.</param>
/// <returns>No content on success.</returns>
[HttpPut]
[ProducesResponseType(StatusCodes.Status204NoContent)]
public async Task<IActionResult> Put([FromBody] UpdateProfileCommand procedure, CancellationToken cancel)
{
await mediator.Send(procedure, cancel);
return NoContent();
}
/// <summary>
/// Deletes profile records via the PROFILE delete procedure for the specified id range.
/// </summary>
/// <param name="procedure">DeleteProfileProcedure payload (Start, End, Force).</param>
/// <param name="cancel">A token to cancel the operation.</param>
/// <returns>No content on success.</returns>
[HttpDelete]
[ProducesResponseType(StatusCodes.Status204NoContent)]
public async Task<IActionResult> Delete([FromBody] DeleteProfileCommand procedure, CancellationToken cancel)
{
await mediator.Send(procedure, cancel);
return NoContent();
}
}