示例#1
0
        public async Task <IActionResult> PostWebhook(string app, string name, [FromBody] CreateWebhookDto request)
        {
            var command = new AddWebhook {
                Url = request.Url
            };

            await CommandBus.PublishAsync(command);

            return(CreatedAtAction(nameof(GetWebhooks), new { app }, SimpleMapper.Map(command, new WebhookCreatedDto())));
        }
示例#2
0
        public async Task <IActionResult> PutWebhook(string app, Guid id, [FromBody] CreateWebhookDto request)
        {
            var schemas = request.Schemas.Select(s => SimpleMapper.Map(s, new WebhookSchema())).ToList();

            var command = new UpdateWebhook {
                WebhookId = id, Url = request.Url, Schemas = schemas
            };

            await CommandBus.PublishAsync(command);

            return(NoContent());
        }
示例#3
0
        public async Task <IActionResult> PostWebhook(string app, string name, [FromBody] CreateWebhookDto request)
        {
            var command = new AddWebhook {
                Url = request.Url
            };

            await CommandBus.PublishAsync(command);

            var response = SimpleMapper.Map(command, new WebhookCreatedDto {
                SchemaId = command.SchemaId.Id.ToString()
            });

            return(CreatedAtAction(nameof(GetWebhooks), new { app }, response));
        }
示例#4
0
        public async Task <IActionResult> PostWebhook(string app, [FromBody] CreateWebhookDto request)
        {
            var schemas = request.Schemas.Select(s => SimpleMapper.Map(s, new WebhookSchema())).ToList();

            var command = new CreateWebhook {
                Url = request.Url, Schemas = schemas
            };

            var context = await CommandBus.PublishAsync(command);

            var result   = context.Result <EntityCreatedResult <Guid> >();
            var response = new WebhookCreatedDto {
                Id = result.IdOrValue, SharedSecret = command.SharedSecret, Version = result.Version
            };

            return(CreatedAtAction(nameof(GetWebhooks), new { app }, response));
        }