Add SP-based update/delete for Catalogs, new endpoints

Added support for updating and deleting Catalog records via SQL Server stored procedures. Introduced PUT /catalogs/sp and DELETE /catalogs/sp/{id} endpoints in CatalogsController. Extended service and repository interfaces and implementations to handle stored procedure operations. Added Microsoft.Data.SqlClient package for direct SQL execution. Repository checks for record existence before SP calls to prevent unintended behavior.
This commit is contained in:
OlgunR
2026-01-12 12:58:41 +01:00
parent d312230803
commit eabf60923d
6 changed files with 87 additions and 0 deletions

View File

@@ -50,6 +50,17 @@ public class CatalogsController : ControllerBase
return NoContent();
}
[HttpPut("sp")]
public async Task<ActionResult<CatalogDto>> UpdateWithStoredProcedure(CatalogDto dto, CancellationToken cancellationToken)
{
var updated = await _service.UpdateWithStoredProcedureAsync(dto, cancellationToken);
if (updated == null)
{
return BadRequest();
}
return Ok(updated);
}
[HttpDelete("{id:int}")]
public async Task<IActionResult> Delete(int id, CancellationToken cancellationToken)
{
@@ -60,4 +71,15 @@ public class CatalogsController : ControllerBase
}
return NoContent();
}
[HttpDelete("sp/{id:int}")]
public async Task<IActionResult> DeleteWithStoredProcedure(int id, CancellationToken cancellationToken)
{
var deleted = await _service.DeleteWithStoredProcedureAsync(id, cancellationToken);
if (!deleted)
{
return NotFound();
}
return NoContent();
}
}