This serivce is an example of Clean Architure. This microservice's responsiblity is to manage things related to a Users & Roles.
This microservice solves all its goals. - a "... well-factored, SOLID applications using .NET Core."
It will demonstrate all SOLID principles. 1. reference link 1 2. reference link 2 3. reference link 3
-
SOLID
-
N-Tiered Architecture
-
Core Components -
CGE.CleanCode.Common
linka. Enums - Shared Enums used in solution projects.
b. Extensions- Shared Extensions used in solution projects.
c. Models -
- Dto - Data Transfer Objects - Used by the Web Api to represnent Database Resources.
- Patches - Models used for
HTTPPatch
requests.
-
SharedKernel Project -
.Common
is our Shared Nuget package used by multiple Microservices. -
Infrastructure Project -
CGE.CleanCode.Services
- This is our Logic layer, the layer with all our Business Logic (Insfrastructure). -
Web Project -
CGE.CleanCode.Api
- This is our internet facing service - the WebApi.
Web Project - CGE.CleanCode.Api
1. `BaseController` ([link](https://github.com/DocGreenRob/clean-.net6-webapi-architecture/blob/main/src/CGE.CleanCode.Api/Controllers/BaseController.cs)) - used to hold objects that are common to all controllers (i.e., `TelemetryClient`, `Configuration`)
2. Lightweight Controller Methods
[HttpDelete("{id}")]
public async Task<IActionResult> DeleteAsync(string id)
{
await _branchService.DeleteAsync(id);
await _serviceBusService.SendMessage(new BranchDto() { Id = id }, PayloadType.BranchDeleted.ToString());
return Ok();
}
-
no try/catch logic and heavy controller methods
-
should use Global Exception handler vs try/catch
-
business logic should not be in controller
a. link 1
b. link 2