public async Task <IActionResult> PublishContent(Guid id) { var command = new PublishContent { ContentId = id }; await CommandBus.PublishAsync(command); return(NoContent()); }
public ContentDomainObject Publish(PublishContent command) { Guard.NotNull(command, nameof(command)); VerifyCreatedAndNotDeleted(); RaiseEvent(SimpleMapper.Map(command, new ContentPublished())); return(this); }
public async Task PublishEventAsync_CanPublishTopicWithContent() { var httpClient = new TestHttpClient(); var invokeClient = new PublishHttpClient(httpClient, new JsonSerializerOptions()); var publishContent = new PublishContent() { PublishObjectParameter = "testparam" }; var task = invokeClient.PublishEventAsync <PublishContent>("test", publishContent); httpClient.Requests.TryDequeue(out var entry).Should().BeTrue(); entry.Request.RequestUri.ToString().Should().Be(GetPublishUrl(3500, "test")); (await entry.Request.Content.ReadAsStringAsync()).Should().Be(JsonSerializer.Serialize(publishContent)); }
public async Task PublishEventAsync_CanPublishTopicWithContent() { var httpClient = new TestHttpClient(); var daprClient = new DaprClientBuilder() .UseGrpcChannelOptions(new GrpcChannelOptions { HttpClient = httpClient }) .Build(); var publishContent = new PublishContent() { PublishObjectParameter = "testparam" }; var task = daprClient.PublishEventAsync <PublishContent>("test", publishContent); httpClient.Requests.TryDequeue(out var entry).Should().BeTrue(); var envelope = await GrpcUtils.GetEnvelopeFromRequestMessageAsync <PublishEventEnvelope>(entry.Request); var jsonFromRequest = envelope.Data.Value.ToStringUtf8(); envelope.Topic.Should().Be("test"); jsonFromRequest.Should().Be(JsonSerializer.Serialize(publishContent)); }
protected Task On(PublishContent command, CommandContext context) { return(handler.UpdateAsync <ContentDomainObject>(context, c => c.Publish(command))); }