예제 #1
0
        public async Task <ActionResult <WebhookDefinition> > Handle([FromBody] SaveWebhookDefinitionRequest request, [FromRoute] ApiVersion apiVersion, CancellationToken cancellationToken)
        {
            var webhookId         = request.Id;
            var webhookDefinition = !string.IsNullOrWhiteSpace(webhookId) ? await _store.FindAsync(new EntityIdSpecification <WebhookDefinition>(webhookId), cancellationToken) : default;

            if (webhookDefinition == null)
            {
                webhookDefinition = new WebhookDefinition
                {
                    Id = !string.IsNullOrWhiteSpace(webhookId) ? webhookId : _idGenerator.Generate(),
                }
            }
            ;

            webhookDefinition.Name            = request.Name.Trim();
            webhookDefinition.Path            = request.Path.Trim();
            webhookDefinition.Description     = request.Description?.Trim();
            webhookDefinition.PayloadTypeName = request.PayloadTypeName?.Trim();
            webhookDefinition.IsEnabled       = request.IsEnabled;

            await _store.SaveAsync(webhookDefinition, cancellationToken);

            return(CreatedAtAction("Handle", "Get", new { id = webhookDefinition.Id, apiVersion = apiVersion.ToString() }, webhookDefinition));
        }
    }
        public async Task SaveAsync(WebhookDefinition entity, CancellationToken cancellationToken = default)
        {
            await _mediator.Publish(new WebhookDefinitionSaving(entity), cancellationToken);

            await _store.SaveAsync(entity, cancellationToken);

            await _mediator.Publish(new WebhookDefinitionSaved(entity), cancellationToken);
        }
예제 #3
0
 public async Task SaveAsync(WebhookDefinition entity, CancellationToken cancellationToken)
 {
     entity = Initialize(entity);
     await _store.SaveAsync(entity, cancellationToken);
 }