Remove Upsert functionality from Catalog API
Removed Upsert endpoint and related service/repository methods. Deleted ExecuteUpsertAsync helper. Insert now throws NotImplementedException as a placeholder. Refactored Delete method in repository; logic unchanged.
This commit is contained in:
@@ -27,14 +27,9 @@ public class CatalogRepository : ICatalogRepository
|
||||
|
||||
public async Task<VwmyCatalog> InsertAsync(VwmyCatalog catalog, CancellationToken cancellationToken = default)
|
||||
{
|
||||
catalog.Guid = 0;
|
||||
var created = await ExecuteUpsertAsync(catalog, cancellationToken);
|
||||
if (created == null)
|
||||
{
|
||||
throw new InvalidOperationException("Failed to insert catalog via stored procedure.");
|
||||
}
|
||||
|
||||
return created;
|
||||
// Platzhalter: Insert-Prozedur folgt.
|
||||
// TODO: Replace with dedicated insert stored procedure invocation.
|
||||
throw new NotImplementedException("Insert stored procedure not implemented yet.");
|
||||
}
|
||||
|
||||
public async Task<VwmyCatalog?> UpdateAsync(int id, VwmyCatalog catalog, CancellationToken cancellationToken = default)
|
||||
@@ -46,33 +41,7 @@ public class CatalogRepository : ICatalogRepository
|
||||
}
|
||||
|
||||
catalog.Guid = id;
|
||||
return await ExecuteUpsertAsync(catalog, cancellationToken);
|
||||
}
|
||||
|
||||
public async Task<VwmyCatalog?> UpsertAsync(VwmyCatalog catalog, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await ExecuteUpsertAsync(catalog, cancellationToken);
|
||||
}
|
||||
|
||||
public async Task<bool> DeleteAsync(int id, CancellationToken cancellationToken = default)
|
||||
{
|
||||
var exists = await _db.VwmyCatalogs.AsNoTracking().AnyAsync(x => x.Guid == id, cancellationToken);
|
||||
if (!exists)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var guidParam = new SqlParameter("@GUID", id);
|
||||
await _db.Database.ExecuteSqlRawAsync(
|
||||
"EXEC dbo.PRTBMY_CATALOG_DELETE @GUID",
|
||||
parameters: new[] { guidParam },
|
||||
cancellationToken: cancellationToken);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private async Task<VwmyCatalog?> ExecuteUpsertAsync(VwmyCatalog catalog, CancellationToken cancellationToken)
|
||||
{
|
||||
var guidParam = new SqlParameter("@GUID", SqlDbType.Int)
|
||||
{
|
||||
Direction = ParameterDirection.InputOutput,
|
||||
@@ -96,4 +65,21 @@ public class CatalogRepository : ICatalogRepository
|
||||
var guid = (int)guidParam.Value;
|
||||
return await _db.VwmyCatalogs.AsNoTracking().FirstOrDefaultAsync(x => x.Guid == guid, cancellationToken);
|
||||
}
|
||||
|
||||
public async Task<bool> DeleteAsync(int id, CancellationToken cancellationToken = default)
|
||||
{
|
||||
var exists = await _db.VwmyCatalogs.AsNoTracking().AnyAsync(x => x.Guid == id, cancellationToken);
|
||||
if (!exists)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var guidParam = new SqlParameter("@GUID", id);
|
||||
await _db.Database.ExecuteSqlRawAsync(
|
||||
"EXEC dbo.PRTBMY_CATALOG_DELETE @GUID",
|
||||
parameters: new[] { guidParam },
|
||||
cancellationToken: cancellationToken);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user