-
-
Notifications
You must be signed in to change notification settings - Fork 522
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'cqrs_with_net5' into extreme_cqrs_with_net5
- Loading branch information
Showing
8 changed files
with
43 additions
and
7 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
...le/Warehouse/Warehouse.Api.Tests/Products/GettingProductDetails/GetProductDetailsTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
using System; | ||
using System; | ||
using System.Net; | ||
using System.Threading.Tasks; | ||
using Core.Testing; | ||
|
2 changes: 1 addition & 1 deletion
2
Sample/Warehouse/Warehouse.Api.Tests/Products/GettingProducts/GetProductsTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
using System; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Net; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
using System; | ||
using System; | ||
using System.ComponentModel; | ||
using System.Net; | ||
using System.Text.Json; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
Sample/Warehouse/Warehouse/Products/GettingProductDetails/GetProductDetails.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
using System; | ||
using System; | ||
using System.Linq; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
2 changes: 1 addition & 1 deletion
2
Sample/Warehouse/Warehouse/Products/RegisteringProduct/RegisterProduct.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
Sample/Warehouse/Warehouse/Products/RegisteringProduct/Route.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} | ||
} | ||
|
||
|