Esempio n. 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));
        }
    }
Esempio n. 2
0
        public async Task <IActionResult> Handle(string webhookDefinitionId, CancellationToken cancellationToken = default)
        {
            var webhookDefinition = await _webhookDefinitionStore.FindAsync(new EntityIdSpecification <WebhookDefinition>(webhookDefinitionId), cancellationToken);

            return(webhookDefinition == null ? (IActionResult)NotFound() : Json(webhookDefinition, _serializerSettingsProvider.GetSettings()));
        }
 public Task <WebhookDefinition?> FindAsync(ISpecification <WebhookDefinition> specification, CancellationToken cancellationToken = default) => _store.FindAsync(specification, cancellationToken);