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:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user