Skip to content

Commit e6a36d9

Browse files
authored
Reorganized Commands to the Application layer for clarity and consistency (#62)
* Reorganized Commands to Application layer for clarity and consistency * Updated diagrams
1 parent 7edec14 commit e6a36d9

File tree

73 files changed

+626
-597
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+626
-597
lines changed

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,19 @@ This project is an experimental full-stack application I use to combine several
2020
---
2121

2222
## Architecture
23-
<a href="images/diagram.jpg" target="_blank">
24-
<img src="images/diagram.jpg"/>
23+
24+
### High-Level System Architecture
25+
<a href="images/EcommerceDDD-hl-architecture.png" target="_blank">
26+
<img src="images/EcommerceDDD-hl-architecture.png"/>
2527
</a>
2628

29+
30+
### Detailed Architecture
31+
<a href="images/EcommerceDDD-detailed-architecture.png" target="_blank">
32+
<img src="images/EcommerceDDD-detailed-architecture.png"/>
33+
</a>
34+
35+
2736
```
2837
├── Core
2938
├── Core.Infrastructure
136 KB
Loading
140 KB
Loading

images/diagram.jpg

-121 KB
Binary file not shown.

src/Services/EcommerceDDD.CustomerManagement.Tests/GlobalUsings.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
global using EcommerceDDD.CustomerManagement.Application.RegisteringCustomer;
1414
global using EcommerceDDD.CustomerManagement.Application.UpdatingCustomerInformation;
1515
global using EcommerceDDD.CustomerManagement.Domain;
16-
global using EcommerceDDD.CustomerManagement.Domain.Commands;
1716
global using EcommerceDDD.CustomerManagement.Domain.Events;
1817
global using EcommerceDDD.CustomerManagement.Infrastructure.Projections;
1918
global using EcommerceDDD.ServiceClients.ApiGateway;

src/Services/EcommerceDDD.CustomerManagement/API/Controllers/CustomersController.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
namespace EcommerceDDD.CustomerManagement.API.Controllers;
1+
using EcommerceDDD.CustomerManagement.Application.UpdatingCustomerInformation;
2+
3+
namespace EcommerceDDD.CustomerManagement.API.Controllers;
24

35
[Authorize]
46
[ApiController]
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
namespace EcommerceDDD.CustomerManagement.Application.RegisteringCustomer;
2+
3+
public record class RegisterCustomer : ICommand
4+
{
5+
public string Email { get; private set; }
6+
public string Password { get; private set; }
7+
public string PasswordConfirm { get; private set; }
8+
public string Name { get; private set; }
9+
public string ShippingAddress { get; private set; }
10+
public decimal CreditLimit { get; private set; }
11+
12+
public static RegisterCustomer Create(
13+
string email,
14+
string password,
15+
string passwordConfirm,
16+
string name,
17+
string shippingAddress,
18+
decimal creditLimit)
19+
{
20+
if (string.IsNullOrEmpty(email))
21+
throw new ArgumentNullException(nameof(email));
22+
if (string.IsNullOrEmpty(password))
23+
throw new ArgumentNullException(nameof(password));
24+
if (string.IsNullOrEmpty(passwordConfirm))
25+
throw new ArgumentNullException(nameof(passwordConfirm));
26+
if (string.IsNullOrEmpty(name))
27+
throw new ArgumentNullException(nameof(name));
28+
if (string.IsNullOrEmpty(shippingAddress))
29+
throw new ArgumentNullException(nameof(shippingAddress));
30+
if (creditLimit <= 0)
31+
throw new ArgumentOutOfRangeException(nameof(creditLimit));
32+
33+
return new RegisterCustomer(email,
34+
password,
35+
passwordConfirm,
36+
name,
37+
shippingAddress,
38+
creditLimit);
39+
}
40+
41+
private RegisterCustomer(
42+
string email,
43+
string password,
44+
string passwordConfirm,
45+
string name,
46+
string shippingAddress,
47+
decimal creditLimit)
48+
{
49+
Email = email;
50+
Password = password;
51+
PasswordConfirm = passwordConfirm;
52+
Name = name;
53+
ShippingAddress = shippingAddress;
54+
CreditLimit = creditLimit;
55+
}
56+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
namespace EcommerceDDD.CustomerManagement.Application.UpdatingCustomerInformation;
2+
3+
public record class UpdateCustomerInformation : ICommand
4+
{
5+
public string Name { get; private set; }
6+
public string ShippingAddress { get; private set; }
7+
public decimal CreditLimit { get; private set; }
8+
9+
public static UpdateCustomerInformation Create(
10+
string name,
11+
string shippingAddress,
12+
decimal creditLimit)
13+
{
14+
if (string.IsNullOrEmpty(name))
15+
throw new ArgumentNullException(nameof(name));
16+
if (string.IsNullOrEmpty(shippingAddress))
17+
throw new ArgumentNullException(nameof(shippingAddress));
18+
if (creditLimit <= 0)
19+
throw new ArgumentOutOfRangeException(nameof(creditLimit));
20+
21+
return new UpdateCustomerInformation(
22+
name,
23+
shippingAddress,
24+
creditLimit);
25+
}
26+
27+
private UpdateCustomerInformation(
28+
string name,
29+
string shippingAddress,
30+
decimal creditLimit)
31+
{
32+
Name = name;
33+
ShippingAddress = shippingAddress;
34+
CreditLimit = creditLimit;
35+
}
36+
}

src/Services/EcommerceDDD.CustomerManagement/Domain/Commands/RegisterCustomer.cs

Lines changed: 0 additions & 56 deletions
This file was deleted.

src/Services/EcommerceDDD.CustomerManagement/Domain/Commands/UpdateCustomerInformation.cs

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)