public async Task <OperationResult> DeleteAsync( long roleId, ulong performedById, CancellationToken cancellationToken) { RolesLogMessages.RoleDeleting(_logger, roleId, performedById); using var transactionScope = _transactionScopeFactory.CreateScope(); TransactionsLogMessages.TransactionScopeCreated(_logger); var actionId = await _auditableActionsRepository.CreateAsync( (int)RoleManagementAdministrationActionType.RoleDeleted, _systemClock.UtcNow, performedById, cancellationToken); AuditingLogMessages.AuditingActionCreated(_logger, actionId); var deleteResult = await _rolesRepository.UpdateAsync( roleId : roleId, actionId : actionId, isDeleted : true, cancellationToken : cancellationToken); if (deleteResult.IsSuccess) { RolesLogMessages.RoleDeleted(_logger, roleId, deleteResult.Value); _memoryCache.Remove(_getCurrentIdentitiesCacheKey); RolesLogMessages.RoleIdentitiesCacheCleared(_logger); RolesLogMessages.RoleDeletingNotificationPublishing(_logger, roleId); await _messenger.PublishNotificationAsync( new RoleDeletingNotification( roleId, actionId), cancellationToken); RolesLogMessages.RoleDeletingNotificationPublished(_logger, roleId); transactionScope.Complete(); TransactionsLogMessages.TransactionScopeCommitted(_logger); } else { RolesLogMessages.RoleDeleteFailed(_logger, roleId, deleteResult); } return(deleteResult); }