Skip to content

Commit

Permalink
Merge branch 'cqrs_with_net5' into extreme_cqrs_with_net5
Browse files Browse the repository at this point in the history
  • Loading branch information
oskardudycz committed May 17, 2021
2 parents 5a03a65 + 54fdc6b commit bb5ca4d
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 7 deletions.
@@ -1,4 +1,4 @@
using System;
using System;
using System.Net;
using System.Threading.Tasks;
using Core.Testing;
Expand Down
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
Expand Down
@@ -1,4 +1,4 @@
using System;
using System;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
Expand Down
@@ -1,4 +1,4 @@
using System;
using System;
using System.ComponentModel;
using System.Net;
using System.Text.Json;
Expand Down
2 changes: 1 addition & 1 deletion Sample/Warehouse/Warehouse/Products/Configuration.cs
@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Net;
using Microsoft.AspNetCore.Routing;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http;
Expand Down
@@ -1,4 +1,4 @@
using System;
using System;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
Expand Down
@@ -1,4 +1,4 @@
using System;
using System;
using System.Text.Json.Serialization;
using System.Threading;
using System.Threading.Tasks;
Expand Down
36 changes: 36 additions & 0 deletions Sample/Warehouse/Warehouse/Products/RegisteringProduct/Route.cs
@@ -0,0 +1,36 @@
using System;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Routing;
using Warehouse.Core.Commands;
using Warehouse.Core.Extensions;

namespace Warehouse.Products.RegisteringProduct
{
public record RegisterProductRequest(
string? SKU,
string? Name,
string? Description
);

internal static class Route
{
internal static IEndpointRouteBuilder UseRegisterProductEndpoint(this IEndpointRouteBuilder endpoints)
{
endpoints.MapPost("api/products/", async context =>
{
var (sku, name, description) = await context.FromBody<RegisterProductRequest>();
var productId = Guid.NewGuid();
var command = RegisterProduct.Create(productId, sku, name, description);
await context.SendCommand(command);
await context.Created(productId);
});

return endpoints;
}
}
}


0 comments on commit bb5ca4d

Please sign in to comment.