Allow soft-deleting certificate paths from settings.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-07-29 09:55:29 +02:00
co-authored by Cursor
parent b1e1789fd1
commit aac71ec2cd
3 changed files with 134 additions and 2 deletions
@@ -1299,6 +1299,53 @@ public sealed class SonicSetupRepository
return Convert.ToInt32(result);
}
public async Task DeactivateCertificateTargetAsync(
int certificateTargetId,
CancellationToken cancellationToken = default)
{
if (certificateTargetId <= 0)
{
throw new ArgumentOutOfRangeException(
nameof(certificateTargetId));
}
const string sql = """
UPDATE [dbo].[CertificateTarget]
SET
[IsActive] = 0,
[ModifiedDateTime] = SYSUTCDATETIME(),
[ModifiedBy] = SUSER_SNAME()
WHERE [CertificateTargetId] = @CertificateTargetId
AND [IsActive] = 1;
""";
await using SqlConnection connection =
new(_connectionString);
await connection.OpenAsync(cancellationToken);
await using SqlCommand command =
new(sql, connection);
command.Parameters.Add(
new SqlParameter(
"@CertificateTargetId",
SqlDbType.Int)
{
Value = certificateTargetId
});
int affected =
await command.ExecuteNonQueryAsync(cancellationToken);
if (affected == 0)
{
throw new InvalidOperationException(
$"Zertifikat-Pfad Id {certificateTargetId} "
+ "wurde nicht gefunden oder ist bereits inaktiv.");
}
}
public async Task<bool> ExistsSonicConnectionAsync(
int sonicConnectionId,
CancellationToken cancellationToken = default)