public async Task <int> DeleteManyAsync(ISpecification <WebhookDefinition> specification, CancellationToken cancellationToken = default)
        {
            var webhookDefinitions = await FindManyAsync(specification, cancellationToken : cancellationToken).ToList();

            if (!webhookDefinitions.Any())
            {
                return(0);
            }

            foreach (var webhookDefinition in webhookDefinitions)
            {
                await _mediator.Publish(new WebhookDefinitionDeleting(webhookDefinition), cancellationToken);
            }

            await _mediator.Publish(new ManyWebhookDefinitionsDeleting(webhookDefinitions), cancellationToken);

            var count = await _store.DeleteManyAsync(specification, cancellationToken);

            foreach (var instance in webhookDefinitions)
            {
                await _mediator.Publish(new WebhookDefinitionDeleted(instance), cancellationToken);
            }

            await _mediator.Publish(new ManyWebhookDefinitionsDeleted(webhookDefinitions), cancellationToken);

            return(count);
        }
Пример #2
0
 public Task <int> DeleteManyAsync(ISpecification <WebhookDefinition> specification, CancellationToken cancellationToken) => _store.DeleteManyAsync(specification, cancellationToken);