Allow soft-deleting certificate paths from settings.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user