Justin Kotalik
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with
13 additions and
9 deletions
-
samples/dapr/orders/Controllers/OrdersController.cs
-
samples/dapr/orders/orders.csproj
-
samples/dapr/products/products.csproj
-
samples/dapr/store/Shared/ProductDisplay.razor
-
samples/dapr/store/Startup.cs
-
samples/dapr/store/store.csproj
|
|
|
@ -10,7 +10,7 @@ namespace orders.Controllers |
|
|
|
[ApiController] |
|
|
|
public class OrdersController : ControllerBase |
|
|
|
{ |
|
|
|
[Topic("orderplaced")] |
|
|
|
[Topic("messagebus", "orderplaced")] |
|
|
|
[HttpPost("orderplaced")] |
|
|
|
public async Task PlaceOrder(Order order, [FromServices] DaprClient dapr, [FromServices] ILogger<OrdersController> logger) |
|
|
|
{ |
|
|
|
@ -49,7 +49,7 @@ namespace orders.Controllers |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
await dapr.PublishEventAsync("orderprocessed", confirmation); |
|
|
|
await dapr.PublishEventAsync("messagebus", "orderprocessed", confirmation); |
|
|
|
|
|
|
|
logger.LogInformation("Sent confirmation for order {OrderId}", order.OrderId); |
|
|
|
|
|
|
|
|
|
|
|
@ -5,7 +5,7 @@ |
|
|
|
</PropertyGroup> |
|
|
|
|
|
|
|
<ItemGroup> |
|
|
|
<PackageReference Include="Dapr.AspNetCore" Version="0.8.0-preview01" /> |
|
|
|
<PackageReference Include="Dapr.AspNetCore" Version="0.11.0-preview02" /> |
|
|
|
</ItemGroup> |
|
|
|
|
|
|
|
</Project> |
|
|
|
|
|
|
|
@ -5,7 +5,7 @@ |
|
|
|
</PropertyGroup> |
|
|
|
|
|
|
|
<ItemGroup> |
|
|
|
<PackageReference Include="Dapr.AspNetCore" Version="0.8.0-preview01" /> |
|
|
|
<PackageReference Include="Dapr.AspNetCore" Version="0.11.0-preview02" /> |
|
|
|
</ItemGroup> |
|
|
|
|
|
|
|
</Project> |
|
|
|
|
|
|
|
@ -46,7 +46,7 @@ |
|
|
|
|
|
|
|
var task = Broker.GetOrderConfirmationAsync(orderId, cts.Token); |
|
|
|
|
|
|
|
await Dapr.PublishEventAsync("orderplaced", new Order() |
|
|
|
await Dapr.PublishEventAsync("messagebus", "orderplaced", new Order() |
|
|
|
{ |
|
|
|
ProductId = Product.Id, |
|
|
|
OrderId = orderId, |
|
|
|
|
|
|
|
@ -1,6 +1,7 @@ |
|
|
|
using System; |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
|
using System.Text; |
|
|
|
using System.Text.Json; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Microsoft.AspNetCore.Builder; |
|
|
|
@ -63,9 +64,12 @@ namespace store |
|
|
|
var broker = endpoints.ServiceProvider.GetRequiredService<OrdersEventBroker>(); |
|
|
|
endpoints.MapPost("/orderprocessed", async context => |
|
|
|
{ |
|
|
|
var confirmation = await JsonSerializer.DeserializeAsync<OrderConfirmation>(context.Request.Body); |
|
|
|
var confirmation = await JsonSerializer.DeserializeAsync<OrderConfirmation>(context.Request.Body, new JsonSerializerOptions() |
|
|
|
{ |
|
|
|
PropertyNameCaseInsensitive = true |
|
|
|
}); |
|
|
|
broker.Complete(confirmation); |
|
|
|
}).WithTopic("orderprocessed"); |
|
|
|
}).WithTopic("messagebus", "orderprocessed"); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -5,7 +5,7 @@ |
|
|
|
</PropertyGroup> |
|
|
|
|
|
|
|
<ItemGroup> |
|
|
|
<PackageReference Include="Dapr.AspNetCore" Version="0.8.0-preview01" /> |
|
|
|
<PackageReference Include="Dapr.AspNetCore" Version="0.11.0-preview02" /> |
|
|
|
</ItemGroup> |
|
|
|
|
|
|
|
</Project> |
|
|
|
|