Add [FromBody] to DTO params in controller actions

Explicitly annotate DTO parameters with [FromBody] in CatalogsController (Create, Update) and MassDataController (Upsert) to ensure correct model binding from the request body and improve API clarity.
This commit is contained in:
OlgunR
2026-04-21 15:22:33 +02:00
parent 087708dcf7
commit b35c167648
2 changed files with 3 additions and 3 deletions

View File

@@ -36,7 +36,7 @@ public class CatalogsController : ControllerBase
} }
[HttpPost] [HttpPost]
public async Task<ActionResult<CatalogReadDto>> Create(CatalogWriteDto dto, CancellationToken cancellationToken) public async Task<ActionResult<CatalogReadDto>> Create([FromBody]CatalogWriteDto dto, CancellationToken cancellationToken)
{ {
var created = await _mediator.Send(new CreateCatalogCommand(dto), cancellationToken); var created = await _mediator.Send(new CreateCatalogCommand(dto), cancellationToken);
if (created == null) if (created == null)
@@ -47,7 +47,7 @@ public class CatalogsController : ControllerBase
} }
[HttpPut("{id:int}")] [HttpPut("{id:int}")]
public async Task<ActionResult<CatalogReadDto>> Update(int id, CatalogWriteDto dto, CancellationToken cancellationToken) public async Task<ActionResult<CatalogReadDto>> Update(int id, [FromBody] CatalogWriteDto dto, CancellationToken cancellationToken)
{ {
var updated = await _mediator.Send(new UpdateCatalogCommand(id, dto), cancellationToken); var updated = await _mediator.Send(new UpdateCatalogCommand(id, dto), cancellationToken);
if (updated == null) if (updated == null)

View File

@@ -50,7 +50,7 @@ public class MassDataController : ControllerBase
} }
[HttpPost("upsert")] [HttpPost("upsert")]
public async Task<ActionResult<MassDataReadDto>> Upsert(MassDataWriteDto dto, CancellationToken cancellationToken) public async Task<ActionResult<MassDataReadDto>> Upsert([FromBody]MassDataWriteDto dto, CancellationToken cancellationToken)
{ {
var result = await _mediator.Send(new UpsertMassDataByCustomerNameCommand(dto), cancellationToken); var result = await _mediator.Send(new UpsertMassDataByCustomerNameCommand(dto), cancellationToken);
return Ok(result); return Ok(result);