Refactor PUT endpoints to use id in route and DTO in body

Refactored update (PUT) endpoints in multiple controllers to accept the record id as a route parameter and the update data as a DTO in the request body. Updated method signatures, XML documentation, and imports to align with RESTful conventions and improve API clarity. Controller methods now construct command objects using the id and DTO before sending to MediatR.
This commit is contained in:
2026-03-24 12:07:50 +01:00
parent dcfa47c68d
commit daff1477be
6 changed files with 35 additions and 26 deletions

View File

@@ -1,5 +1,6 @@
using MediatR;
using Microsoft.AspNetCore.Mvc;
using ReC.Application.Common.Procedures.UpdateProcedure.Dto;
using ReC.Application.RecActions.Commands;
using ReC.Application.RecActions.Queries;
@@ -52,14 +53,15 @@ public class RecActionController(IMediator mediator) : ControllerBase
/// <summary>
/// Updates a RecAction via the ACTION update procedure.
/// </summary>
/// <param name="procedure">UpdateActionProcedure payload.</param>
/// <param name="id">The identifier of the ACTION record to update.</param>
/// <param name="data">UpdateActionProcedure payload.</param>
/// <param name="cancel">A token to cancel the operation.</param>
/// <returns>No content on success.</returns>
[HttpPut("{id:long}")]
[ProducesResponseType(StatusCodes.Status204NoContent)]
public async Task<IActionResult> Update([FromBody] UpdateActionCommand procedure, CancellationToken cancel)
public async Task<IActionResult> Update([FromRoute] long id, [FromBody] UpdateActionDto data, CancellationToken cancel)
{
await mediator.Send(procedure, cancel);
await mediator.Send(new UpdateActionCommand() { Id = id, Data = data }, cancel);
return NoContent();
}