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:
@@ -40,8 +40,20 @@ public class CatalogService : ICatalogService
|
||||
return await _repository.UpdateAsync(id, domainItem, cancellationToken);
|
||||
}
|
||||
|
||||
public async Task<CatalogDto?> UpdateWithStoredProcedureAsync(CatalogDto dto, CancellationToken cancellationToken = default)
|
||||
{
|
||||
var domainItem = _mapper.Map<Catalog>(dto);
|
||||
var updated = await _repository.UpdateWithStoredProcedureAsync(domainItem, cancellationToken);
|
||||
return updated == null ? null : _mapper.Map<CatalogDto>(updated);
|
||||
}
|
||||
|
||||
public async Task<bool> DeleteAsync(int id, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await _repository.DeleteAsync(id, cancellationToken);
|
||||
}
|
||||
|
||||
public async Task<bool> DeleteWithStoredProcedureAsync(int id, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await _repository.DeleteWithStoredProcedureAsync(id, cancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user