Update SP-based catalog update to use id route param

Refactor UpdateWithStoredProcedure to accept id from the route and set dto.Guid accordingly. In the repository, use Guid for existence checks instead of CAT_TITLE, and ensure CatTitle is not changed via the SP. Improve error handling to return NotFound when appropriate.
This commit is contained in:
OlgunR
2026-01-12 16:39:21 +01:00
parent eabf60923d
commit 97eea94090
2 changed files with 13 additions and 8 deletions

View File

@@ -50,13 +50,14 @@ public class CatalogsController : ControllerBase
return NoContent();
}
[HttpPut("sp")]
public async Task<ActionResult<CatalogDto>> UpdateWithStoredProcedure(CatalogDto dto, CancellationToken cancellationToken)
[HttpPut("sp/{id:int}")]
public async Task<ActionResult<CatalogDto>> UpdateWithStoredProcedure(int id, CatalogDto dto, CancellationToken cancellationToken)
{
dto.Guid = id;
var updated = await _service.UpdateWithStoredProcedureAsync(dto, cancellationToken);
if (updated == null)
{
return BadRequest();
return NotFound();
}
return Ok(updated);
}