public SchemaDomainObject AddWebhook(AddWebhook command) { Guard.Valid(command, nameof(command), () => "Cannot add webhook"); VerifyCreatedAndNotDeleted(); RaiseEvent(SimpleMapper.Map(command, new WebhookAdded())); return(this); }
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()))); }
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)); }
public void AddWebhook_should_update_schema_and_create_events() { var command = new AddWebhook { Url = new Uri("https://cloud.squidex.io") }; CreateSchema(); sut.AddWebhook(CreateCommand(command)); sut.GetUncomittedEvents() .ShouldHaveSameEvents( CreateEvent(new WebhookAdded { Id = command.Id, Url = command.Url, SharedSecret = command.SharedSecret }) ); }
public async Task DeleteWebhook_should_update_domain_object() { var createCommand = new AddWebhook { Url = new Uri("http://cloud.squidex.io") }; CreateSchema(); CreateWebhook(createCommand); var context = CreateContextForCommand(new DeleteWebhook { Id = createCommand.Id }); await TestUpdate(schema, async _ => { await sut.HandleAsync(context); }); }
private void CreateWebhook(AddWebhook command) { schema.AddWebhook(command); }
protected Task On(AddWebhook command, CommandContext context) { return(handler.UpdateAsync <SchemaDomainObject>(context, s => s.AddWebhook(command))); }