Skip to content

Commit bb5ca4d

Browse files
authored
Merge branch 'cqrs_with_net5' into extreme_cqrs_with_net5
2 parents 5a03a65 + 54fdc6b commit bb5ca4d

File tree

8 files changed

+43
-7
lines changed

8 files changed

+43
-7
lines changed

Sample/Warehouse/Warehouse.Api.Tests/Products/GettingProductDetails/GetProductDetailsTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Net;
33
using System.Threading.Tasks;
44
using Core.Testing;

Sample/Warehouse/Warehouse.Api.Tests/Products/GettingProducts/GetProductsTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.Linq;
44
using System.Net;

Sample/Warehouse/Warehouse/Core/Commands/ICommandHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Threading;
33
using System.Threading.Tasks;
44
using Microsoft.AspNetCore.Http;

Sample/Warehouse/Warehouse/Core/Extensions/HttpExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.ComponentModel;
33
using System.Net;
44
using System.Text.Json;

Sample/Warehouse/Warehouse/Products/Configuration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Collections.Generic;
1+
using System.Collections.Generic;
22
using System.Net;
33
using Microsoft.AspNetCore.Routing;
44
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http;

Sample/Warehouse/Warehouse/Products/GettingProductDetails/GetProductDetails.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Linq;
33
using System.Threading;
44
using System.Threading.Tasks;

Sample/Warehouse/Warehouse/Products/RegisteringProduct/RegisterProduct.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Text.Json.Serialization;
33
using System.Threading;
44
using System.Threading.Tasks;
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System;
2+
using Microsoft.AspNetCore.Builder;
3+
using Microsoft.AspNetCore.Routing;
4+
using Warehouse.Core.Commands;
5+
using Warehouse.Core.Extensions;
6+
7+
namespace Warehouse.Products.RegisteringProduct
8+
{
9+
public record RegisterProductRequest(
10+
string? SKU,
11+
string? Name,
12+
string? Description
13+
);
14+
15+
internal static class Route
16+
{
17+
internal static IEndpointRouteBuilder UseRegisterProductEndpoint(this IEndpointRouteBuilder endpoints)
18+
{
19+
endpoints.MapPost("api/products/", async context =>
20+
{
21+
var (sku, name, description) = await context.FromBody<RegisterProductRequest>();
22+
var productId = Guid.NewGuid();
23+
24+
var command = RegisterProduct.Create(productId, sku, name, description);
25+
26+
await context.SendCommand(command);
27+
28+
await context.Created(productId);
29+
});
30+
31+
return endpoints;
32+
}
33+
}
34+
}
35+
36+

0 commit comments

Comments
 (0)