├── .circleci
└── config.yml
├── .gitattributes
├── .github
└── workflows
│ ├── build.yml
│ └── dotnet-core.yml
├── .gitignore
├── .sonar-project.properties
├── LICENSE
├── ModularArch.sln
├── appveyor.yml
├── docs
├── .nojekyll
├── README.md
├── Step1-initial.ps1
├── Step2-execute.ps1
├── img
│ ├── Modular-arch.drawio
│ ├── Modular-arch.png
│ ├── Module1.drawio
│ ├── Module1.png
│ ├── Module2.drawio
│ ├── Module2.png
│ ├── SolutionExplorer.png
│ ├── logo.drawio
│ └── logo.png
├── index.html
└── plans
├── script.ps1.txt
├── src
├── .template.config
│ └── template.json
├── HA.Adapter.DealModule.Unit.Test
│ ├── EventHandlers
│ │ └── CreateDealCommandHandlerTest.cs
│ └── HA.Module.Deal.Unit.Test.csproj
├── HA.Adapter.DealModule
│ ├── Commands
│ │ ├── CreateDealCommand.cs
│ │ ├── DeleteDealCommand.cs
│ │ └── UpdateDealCommand.cs
│ ├── Controllers
│ │ ├── v1
│ │ │ └── DealController.cs
│ │ └── v2
│ │ │ └── ValuesController.cs
│ ├── DealModuleExtensions.cs
│ ├── EventHandlers
│ │ ├── CreateDealCommandHandler.cs
│ │ ├── DeleteDealCommandHandler.cs
│ │ └── UpdateDealCommandHandler.cs
│ ├── HA.Module.Deal.csproj
│ ├── Mapping
│ │ └── DealMapping.cs
│ ├── Queries
│ │ ├── GetAllDealsQuery.cs
│ │ └── GetDealByIdQuery.cs
│ ├── Validation
│ │ ├── CreateDealCommandValidator.cs
│ │ ├── DeleteDealCommandValidator.cs
│ │ └── UpdateDealCommandValidator.cs
│ └── ViewModel
│ │ └── DealViewModel.cs
├── HA.Adapter.Persistence.Unit.Test
│ ├── Common
│ │ └── ApplicationDbContextFactory.cs
│ ├── Context
│ │ └── ApplicationDbContextTest.cs
│ ├── HA.Module.Persistence.Unit.Test.csproj
│ └── Repositories
│ │ └── GenericRepositoryAsyncTest.cs
├── HA.Adapter.Persistence
│ ├── Configurations
│ │ └── DealConfig.cs
│ ├── Context
│ │ ├── ApplicationDbContext.cs
│ │ └── ContextSeed.cs
│ ├── HA.Module.Persistence.csproj
│ ├── PersistenceExtensions.cs
│ └── Repositories
│ │ └── GenericRepositoryAsync.cs
├── HA.Application.Unit.Test
│ ├── Exceptions.cs
│ └── HA.Application.Unit.Test.csproj
├── HA.Application
│ ├── ApplicationExtension.cs
│ ├── Behaviours
│ │ └── ValidationBehavior.cs
│ ├── Contract
│ │ ├── IGenericRepositoryAsync.cs
│ │ └── IMapFrom.cs
│ ├── Controllers
│ │ └── BaseController.cs
│ ├── Exceptions
│ │ ├── ApiExceptions.cs
│ │ ├── BadRequestException.cs
│ │ ├── DeleteFailureException.cs
│ │ ├── NotFoundException.cs
│ │ └── ValidationException.cs
│ ├── HA.Application.csproj
│ └── Middleware
│ │ └── CustomExceptionHandlerMiddleware.cs
├── HA.DatabaseMigration
│ ├── HA.DatabaseMigration.csproj
│ ├── Program.cs
│ ├── Properties
│ │ └── launchSettings.json
│ ├── Startup.cs
│ ├── appsettings.Development.json
│ └── appsettings.json
├── HA.Domain.Unit.Test
│ ├── Entities
│ │ └── DealTest.cs
│ ├── HA.Domain.Unit.Test.csproj
│ └── Services
│ │ └── ApplicationDetailTest.cs
├── HA.Domain
│ ├── Common
│ │ ├── AggregateRoot.cs
│ │ ├── AuditLogEntry.cs
│ │ ├── BaseEntity.cs
│ │ └── IHasKey.cs
│ ├── Entities
│ │ └── Deal.cs
│ ├── HA.Domain.csproj
│ └── Services
│ │ ├── AppSettings.cs
│ │ ├── ApplicationDetail.cs
│ │ ├── ConnectionStrings.cs
│ │ ├── DataShaper.cs
│ │ ├── PagedList.cs
│ │ ├── PagedResponse.cs
│ │ └── QueryStringParameters.cs
├── HA.GraphQL
│ ├── GraphQL.postman_collection.json
│ ├── GraphQL
│ │ ├── DealSchema.cs
│ │ ├── Queries
│ │ │ └── DealQuery.cs
│ │ └── Types
│ │ │ └── DealGraphType.cs
│ ├── HA.GraphQL.csproj
│ ├── Program.cs
│ ├── Properties
│ │ └── launchSettings.json
│ ├── Query-schema.txt
│ ├── Startup.cs
│ ├── appsettings.Development.json
│ └── appsettings.json
├── HA.WebAPI.Integration.Test
│ ├── DealApiTest.cs
│ ├── HA.WebAPI.Integration.Test.csproj
│ └── TestClientProvider.cs
└── HA.WebAPI
│ ├── Controllers
│ └── MetaController.cs
│ ├── HA.WebAPI.csproj
│ ├── HA.WebAPI.xml
│ ├── Program.cs
│ ├── Properties
│ └── launchSettings.json
│ ├── Startup.cs
│ ├── appsettings.Development.json
│ └── appsettings.json
└── url.txt
/.circleci/config.yml:
--------------------------------------------------------------------------------
1 | version: 2.1
2 |
3 | orbs:
4 | win: circleci/windows@2.2.0
5 |
6 | jobs:
7 | build:
8 | executor: win/default
9 |
10 | steps:
11 | - checkout
12 | - run: dotnet build
13 | - run: dotnet test
14 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/.github/workflows/build.yml:
--------------------------------------------------------------------------------
1 | name: Build CI
2 | on:
3 | push:
4 | branches:
5 | - main
6 | pull_request:
7 | types: [opened, synchronize, reopened]
8 | jobs:
9 | build:
10 | name: Build
11 | runs-on: windows-latest
12 | steps:
13 | - name: Set up JDK 11
14 | uses: actions/setup-java@v1
15 | with:
16 | java-version: 1.11
17 | - uses: actions/checkout@v2
18 | with:
19 | fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
20 | - name: Cache SonarCloud packages
21 | uses: actions/cache@v1
22 | with:
23 | path: ~\sonar\cache
24 | key: ${{ runner.os }}-sonar
25 | restore-keys: ${{ runner.os }}-sonar
26 | - name: Cache SonarCloud scanner
27 | id: cache-sonar-scanner
28 | uses: actions/cache@v1
29 | with:
30 | path: .\.sonar\scanner
31 | key: ${{ runner.os }}-sonar-scanner
32 | restore-keys: ${{ runner.os }}-sonar-scanner
33 | - name: Install SonarCloud scanner
34 | if: steps.cache-sonar-scanner.outputs.cache-hit != 'true'
35 | shell: powershell
36 | run: |
37 | New-Item -Path .\.sonar\scanner -ItemType Directory
38 | dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner
39 | - name: Build and analyze
40 | env:
41 | # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
42 | SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
43 | shell: powershell
44 | run: |
45 | .\.sonar\scanner\dotnet-sonarscanner begin /k:"Amitpnk_Modular-Architecture-ASP.NET-Core" /o:"amitpnk" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io"
46 | dotnet build --configuration Release --no-restore ModularArch.sln
47 | .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
--------------------------------------------------------------------------------
/.github/workflows/dotnet-core.yml:
--------------------------------------------------------------------------------
1 | name: .NET Core
2 |
3 | on: [push]
4 |
5 | jobs:
6 | build:
7 |
8 | runs-on: ubuntu-latest
9 |
10 | steps:
11 | - uses: actions/checkout@v2
12 | - name: Setup .NET Core
13 | uses: actions/setup-dotnet@v1
14 | with:
15 | dotnet-version: 3.1.301
16 | - name: Install dependencies
17 | run: dotnet restore
18 | - name: Build
19 | run: dotnet build --configuration Release --no-restore
20 | - name: Test
21 | run: dotnet test --no-restore --verbosity normal
22 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.rsuser
8 | *.suo
9 | *.user
10 | *.userosscache
11 | *.sln.docstates
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Mono auto generated files
17 | mono_crash.*
18 |
19 | # Build results
20 | [Dd]ebug/
21 | [Dd]ebugPublic/
22 | [Rr]elease/
23 | [Rr]eleases/
24 | x64/
25 | x86/
26 | [Aa][Rr][Mm]/
27 | [Aa][Rr][Mm]64/
28 | bld/
29 | [Bb]in/
30 | [Oo]bj/
31 | [Ll]og/
32 | [Ll]ogs/
33 |
34 | # Visual Studio 2015/2017 cache/options directory
35 | .vs/
36 | # Uncomment if you have tasks that create the project's static files in wwwroot
37 | #wwwroot/
38 |
39 | # Visual Studio 2017 auto generated files
40 | Generated\ Files/
41 |
42 | # MSTest test Results
43 | [Tt]est[Rr]esult*/
44 | [Bb]uild[Ll]og.*
45 |
46 | # NUnit
47 | *.VisualState.xml
48 | TestResult.xml
49 | nunit-*.xml
50 |
51 | # Build Results of an ATL Project
52 | [Dd]ebugPS/
53 | [Rr]eleasePS/
54 | dlldata.c
55 |
56 | # Benchmark Results
57 | BenchmarkDotNet.Artifacts/
58 |
59 | # .NET Core
60 | project.lock.json
61 | project.fragment.lock.json
62 | artifacts/
63 |
64 | # StyleCop
65 | StyleCopReport.xml
66 |
67 | # Files built by Visual Studio
68 | *_i.c
69 | *_p.c
70 | *_h.h
71 | *.ilk
72 | *.meta
73 | *.obj
74 | *.iobj
75 | *.pch
76 | *.pdb
77 | *.ipdb
78 | *.pgc
79 | *.pgd
80 | *.rsp
81 | *.sbr
82 | *.tlb
83 | *.tli
84 | *.tlh
85 | *.tmp
86 | *.tmp_proj
87 | *_wpftmp.csproj
88 | *.log
89 | *.vspscc
90 | *.vssscc
91 | .builds
92 | *.pidb
93 | *.svclog
94 | *.scc
95 |
96 | # Chutzpah Test files
97 | _Chutzpah*
98 |
99 | # Visual C++ cache files
100 | ipch/
101 | *.aps
102 | *.ncb
103 | *.opendb
104 | *.opensdf
105 | *.sdf
106 | *.cachefile
107 | *.VC.db
108 | *.VC.VC.opendb
109 |
110 | # Visual Studio profiler
111 | *.psess
112 | *.vsp
113 | *.vspx
114 | *.sap
115 |
116 | # Visual Studio Trace Files
117 | *.e2e
118 |
119 | # TFS 2012 Local Workspace
120 | $tf/
121 |
122 | # Guidance Automation Toolkit
123 | *.gpState
124 |
125 | # ReSharper is a .NET coding add-in
126 | _ReSharper*/
127 | *.[Rr]e[Ss]harper
128 | *.DotSettings.user
129 |
130 | # JustCode is a .NET coding add-in
131 | .JustCode
132 |
133 | # TeamCity is a build add-in
134 | _TeamCity*
135 |
136 | # DotCover is a Code Coverage Tool
137 | *.dotCover
138 |
139 | # AxoCover is a Code Coverage Tool
140 | .axoCover/*
141 | !.axoCover/settings.json
142 |
143 | # Visual Studio code coverage results
144 | *.coverage
145 | *.coveragexml
146 |
147 | # NCrunch
148 | _NCrunch_*
149 | .*crunch*.local.xml
150 | nCrunchTemp_*
151 |
152 | # MightyMoose
153 | *.mm.*
154 | AutoTest.Net/
155 |
156 | # Web workbench (sass)
157 | .sass-cache/
158 |
159 | # Installshield output folder
160 | [Ee]xpress/
161 |
162 | # DocProject is a documentation generator add-in
163 | DocProject/buildhelp/
164 | DocProject/Help/*.HxT
165 | DocProject/Help/*.HxC
166 | DocProject/Help/*.hhc
167 | DocProject/Help/*.hhk
168 | DocProject/Help/*.hhp
169 | DocProject/Help/Html2
170 | DocProject/Help/html
171 |
172 | # Click-Once directory
173 | publish/
174 |
175 | # Publish Web Output
176 | *.[Pp]ublish.xml
177 | *.azurePubxml
178 | # Note: Comment the next line if you want to checkin your web deploy settings,
179 | # but database connection strings (with potential passwords) will be unencrypted
180 | *.pubxml
181 | *.publishproj
182 |
183 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
184 | # checkin your Azure Web App publish settings, but sensitive information contained
185 | # in these scripts will be unencrypted
186 | PublishScripts/
187 |
188 | # NuGet Packages
189 | *.nupkg
190 | # NuGet Symbol Packages
191 | *.snupkg
192 | # The packages folder can be ignored because of Package Restore
193 | **/[Pp]ackages/*
194 | # except build/, which is used as an MSBuild target.
195 | !**/[Pp]ackages/build/
196 | # Uncomment if necessary however generally it will be regenerated when needed
197 | #!**/[Pp]ackages/repositories.config
198 | # NuGet v3's project.json files produces more ignorable files
199 | *.nuget.props
200 | *.nuget.targets
201 |
202 | # Microsoft Azure Build Output
203 | csx/
204 | *.build.csdef
205 |
206 | # Microsoft Azure Emulator
207 | ecf/
208 | rcf/
209 |
210 | # Windows Store app package directories and files
211 | AppPackages/
212 | BundleArtifacts/
213 | Package.StoreAssociation.xml
214 | _pkginfo.txt
215 | *.appx
216 | *.appxbundle
217 | *.appxupload
218 |
219 | # Visual Studio cache files
220 | # files ending in .cache can be ignored
221 | *.[Cc]ache
222 | # but keep track of directories ending in .cache
223 | !?*.[Cc]ache/
224 |
225 | # Others
226 | ClientBin/
227 | ~$*
228 | *~
229 | *.dbmdl
230 | *.dbproj.schemaview
231 | *.jfm
232 | *.pfx
233 | *.publishsettings
234 | orleans.codegen.cs
235 |
236 | # Including strong name files can present a security risk
237 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
238 | #*.snk
239 |
240 | # Since there are multiple workflows, uncomment next line to ignore bower_components
241 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
242 | #bower_components/
243 |
244 | # RIA/Silverlight projects
245 | Generated_Code/
246 |
247 | # Backup & report files from converting an old project file
248 | # to a newer Visual Studio version. Backup files are not needed,
249 | # because we have git ;-)
250 | _UpgradeReport_Files/
251 | Backup*/
252 | UpgradeLog*.XML
253 | UpgradeLog*.htm
254 | ServiceFabricBackup/
255 | *.rptproj.bak
256 |
257 | # SQL Server files
258 | *.mdf
259 | *.ldf
260 | *.ndf
261 |
262 | # Business Intelligence projects
263 | *.rdl.data
264 | *.bim.layout
265 | *.bim_*.settings
266 | *.rptproj.rsuser
267 | *- [Bb]ackup.rdl
268 | *- [Bb]ackup ([0-9]).rdl
269 | *- [Bb]ackup ([0-9][0-9]).rdl
270 |
271 | # Microsoft Fakes
272 | FakesAssemblies/
273 |
274 | # GhostDoc plugin setting file
275 | *.GhostDoc.xml
276 |
277 | # Node.js Tools for Visual Studio
278 | .ntvs_analysis.dat
279 | node_modules/
280 |
281 | # Visual Studio 6 build log
282 | *.plg
283 |
284 | # Visual Studio 6 workspace options file
285 | *.opt
286 |
287 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
288 | *.vbw
289 |
290 | # Visual Studio LightSwitch build output
291 | **/*.HTMLClient/GeneratedArtifacts
292 | **/*.DesktopClient/GeneratedArtifacts
293 | **/*.DesktopClient/ModelManifest.xml
294 | **/*.Server/GeneratedArtifacts
295 | **/*.Server/ModelManifest.xml
296 | _Pvt_Extensions
297 |
298 | # Paket dependency manager
299 | .paket/paket.exe
300 | paket-files/
301 |
302 | # FAKE - F# Make
303 | .fake/
304 |
305 | # CodeRush personal settings
306 | .cr/personal
307 |
308 | # Python Tools for Visual Studio (PTVS)
309 | __pycache__/
310 | *.pyc
311 |
312 | # Cake - Uncomment if you are using it
313 | # tools/**
314 | # !tools/packages.config
315 |
316 | # Tabs Studio
317 | *.tss
318 |
319 | # Telerik's JustMock configuration file
320 | *.jmconfig
321 |
322 | # BizTalk build output
323 | *.btp.cs
324 | *.btm.cs
325 | *.odx.cs
326 | *.xsd.cs
327 |
328 | # OpenCover UI analysis results
329 | OpenCover/
330 |
331 | # Azure Stream Analytics local run output
332 | ASALocalRun/
333 |
334 | # MSBuild Binary and Structured Log
335 | *.binlog
336 |
337 | # NVidia Nsight GPU debugger configuration file
338 | *.nvuser
339 |
340 | # MFractors (Xamarin productivity tool) working folder
341 | .mfractor/
342 |
343 | # Local History for Visual Studio
344 | .localhistory/
345 |
346 | # BeatPulse healthcheck temp database
347 | healthchecksdb
348 |
349 | # Backup folder for Package Reference Convert tool in Visual Studio 2017
350 | MigrationBackup/
351 |
352 | # Ionide (cross platform F# VS Code tools) working folder
353 | .ionide/
354 |
355 | # Identity Server 4 tempkey
356 | tempkey.jwk
357 |
358 | # SonarScanner
359 | .sonarqube/
360 |
--------------------------------------------------------------------------------
/.sonar-project.properties:
--------------------------------------------------------------------------------
1 | # sonar.projectKey=Amitpnk_Hexagonal-Architecture-ASP.NET-Core
2 | # sonar.organization=amitpnk
3 |
4 | # # This is the name and version displayed in the SonarCloud UI.
5 | # sonar.projectName=Hexagonal-Architecture-ASP.NET-Core
6 | # sonar.projectVersion=1.0
7 |
8 | # sonar.links.homepage=https://github.com/Amitpnk/Hexagonal-Architecture-ASP.NET-Core
9 | # sonar.links.ci=https://github.com/Amitpnk/Hexagonal-Architecture-ASP.NET-Core
10 |
11 | # # Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
12 | # sonar.sources=src
13 |
14 |
15 | # # Tests
16 | # sonar.tests=Tests
17 | # #sonar.test.inclusions=
18 | # #sonar.test.exclusions=
19 |
20 | # # Coverage report
21 | # sonar.coverageReportPaths=sonarscanner-coverage-report.xml
22 | # #sonar.coverage.exclusions=src/File_to_exclude_in_coverage.swift, \
23 | # # src/Swift-Travis-Sonarcloud-CI/FolderToExcludeFromCoverage/**
24 |
25 | # # Misc
26 | # sonar.host.url=https://sonarcloud.io
27 |
28 | # # Encoding of the source code. Default is default system encoding
29 | # sonar.sourceEncoding=UTF-8
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Amit P Naik
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/ModularArch.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.30225.117
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HA.Domain", "src\HA.Domain\HA.Domain.csproj", "{F5A4869E-5E00-430B-8BFA-E73F1FBEC75E}"
7 | EndProject
8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HA.Application", "src\HA.Application\HA.Application.csproj", "{2ABB1A87-C12F-49F6-B673-5139B4F13606}"
9 | EndProject
10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HA.Module.Persistence", "src\HA.Adapter.Persistence\HA.Module.Persistence.csproj", "{F7B35304-7785-47D4-9239-64FADFB9CA5D}"
11 | EndProject
12 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HA.DatabaseMigration", "src\HA.DatabaseMigration\HA.DatabaseMigration.csproj", "{AD1F253B-2634-467C-BFA4-AD9319CA3AFF}"
13 | EndProject
14 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HA.WebAPI", "src\HA.WebAPI\HA.WebAPI.csproj", "{FF90BAD1-56E8-4351-8CDB-F62B7E6CAFE7}"
15 | EndProject
16 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HA.Module.Deal", "src\HA.Adapter.DealModule\HA.Module.Deal.csproj", "{3116E006-C9B8-4FA3-B61A-533AF18AE153}"
17 | EndProject
18 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Core", "Core", "{F609564E-8C33-4F72-9DC7-4E13D9D52CA3}"
19 | EndProject
20 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Host", "Host", "{71022FAB-B94F-49F7-B44A-ED52288F792D}"
21 | EndProject
22 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Modules", "Modules", "{CE1B7235-D02E-406B-A05E-BE1B0CFD96D1}"
23 | EndProject
24 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DealModule", "DealModule", "{11A8E1B9-2B97-4D7C-B34A-C66FAFFF9015}"
25 | EndProject
26 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DatabaseModule", "DatabaseModule", "{F64CC1CD-DA16-4E69-91B5-8CCA545A6544}"
27 | EndProject
28 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Test", "Test", "{CE2B18FD-E675-431A-8654-8FCA55485E99}"
29 | EndProject
30 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HA.Module.Persistence.Unit.Test", "src\HA.Adapter.Persistence.Unit.Test\HA.Module.Persistence.Unit.Test.csproj", "{27374D26-BB48-4E01-9280-027CEF1BB1B8}"
31 | EndProject
32 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HA.Module.Deal.Unit.Test", "src\HA.Adapter.DealModule.Unit.Test\HA.Module.Deal.Unit.Test.csproj", "{F48B6F9A-F1E1-4F6C-8926-0DCCF8B3BBCE}"
33 | EndProject
34 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HA.Application.Unit.Test", "src\HA.Application.Unit.Test\HA.Application.Unit.Test.csproj", "{84733491-76A1-41D9-8D94-2FDC3E8D8F17}"
35 | EndProject
36 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HA.Domain.Unit.Test", "src\HA.Domain.Unit.Test\HA.Domain.Unit.Test.csproj", "{BA6B2B02-E20C-4E1C-96E9-54BFFAFA9704}"
37 | EndProject
38 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HA.WebAPI.Integration.Test", "src\HA.WebAPI.Integration.Test\HA.WebAPI.Integration.Test.csproj", "{2AAFB4A6-51AC-4ED6-9866-574D2A323E7B}"
39 | EndProject
40 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HA.GraphQL", "src\HA.GraphQL\HA.GraphQL.csproj", "{47A10ED5-CF64-4E8F-9E5D-8D4E9FC2D53E}"
41 | EndProject
42 | Global
43 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
44 | Debug|Any CPU = Debug|Any CPU
45 | Release|Any CPU = Release|Any CPU
46 | EndGlobalSection
47 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
48 | {F5A4869E-5E00-430B-8BFA-E73F1FBEC75E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
49 | {F5A4869E-5E00-430B-8BFA-E73F1FBEC75E}.Debug|Any CPU.Build.0 = Debug|Any CPU
50 | {F5A4869E-5E00-430B-8BFA-E73F1FBEC75E}.Release|Any CPU.ActiveCfg = Release|Any CPU
51 | {F5A4869E-5E00-430B-8BFA-E73F1FBEC75E}.Release|Any CPU.Build.0 = Release|Any CPU
52 | {2ABB1A87-C12F-49F6-B673-5139B4F13606}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
53 | {2ABB1A87-C12F-49F6-B673-5139B4F13606}.Debug|Any CPU.Build.0 = Debug|Any CPU
54 | {2ABB1A87-C12F-49F6-B673-5139B4F13606}.Release|Any CPU.ActiveCfg = Release|Any CPU
55 | {2ABB1A87-C12F-49F6-B673-5139B4F13606}.Release|Any CPU.Build.0 = Release|Any CPU
56 | {F7B35304-7785-47D4-9239-64FADFB9CA5D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
57 | {F7B35304-7785-47D4-9239-64FADFB9CA5D}.Debug|Any CPU.Build.0 = Debug|Any CPU
58 | {F7B35304-7785-47D4-9239-64FADFB9CA5D}.Release|Any CPU.ActiveCfg = Release|Any CPU
59 | {F7B35304-7785-47D4-9239-64FADFB9CA5D}.Release|Any CPU.Build.0 = Release|Any CPU
60 | {AD1F253B-2634-467C-BFA4-AD9319CA3AFF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
61 | {AD1F253B-2634-467C-BFA4-AD9319CA3AFF}.Debug|Any CPU.Build.0 = Debug|Any CPU
62 | {AD1F253B-2634-467C-BFA4-AD9319CA3AFF}.Release|Any CPU.ActiveCfg = Release|Any CPU
63 | {AD1F253B-2634-467C-BFA4-AD9319CA3AFF}.Release|Any CPU.Build.0 = Release|Any CPU
64 | {FF90BAD1-56E8-4351-8CDB-F62B7E6CAFE7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
65 | {FF90BAD1-56E8-4351-8CDB-F62B7E6CAFE7}.Debug|Any CPU.Build.0 = Debug|Any CPU
66 | {FF90BAD1-56E8-4351-8CDB-F62B7E6CAFE7}.Release|Any CPU.ActiveCfg = Release|Any CPU
67 | {FF90BAD1-56E8-4351-8CDB-F62B7E6CAFE7}.Release|Any CPU.Build.0 = Release|Any CPU
68 | {3116E006-C9B8-4FA3-B61A-533AF18AE153}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
69 | {3116E006-C9B8-4FA3-B61A-533AF18AE153}.Debug|Any CPU.Build.0 = Debug|Any CPU
70 | {3116E006-C9B8-4FA3-B61A-533AF18AE153}.Release|Any CPU.ActiveCfg = Release|Any CPU
71 | {3116E006-C9B8-4FA3-B61A-533AF18AE153}.Release|Any CPU.Build.0 = Release|Any CPU
72 | {27374D26-BB48-4E01-9280-027CEF1BB1B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
73 | {27374D26-BB48-4E01-9280-027CEF1BB1B8}.Debug|Any CPU.Build.0 = Debug|Any CPU
74 | {27374D26-BB48-4E01-9280-027CEF1BB1B8}.Release|Any CPU.ActiveCfg = Release|Any CPU
75 | {27374D26-BB48-4E01-9280-027CEF1BB1B8}.Release|Any CPU.Build.0 = Release|Any CPU
76 | {F48B6F9A-F1E1-4F6C-8926-0DCCF8B3BBCE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
77 | {F48B6F9A-F1E1-4F6C-8926-0DCCF8B3BBCE}.Debug|Any CPU.Build.0 = Debug|Any CPU
78 | {F48B6F9A-F1E1-4F6C-8926-0DCCF8B3BBCE}.Release|Any CPU.ActiveCfg = Release|Any CPU
79 | {F48B6F9A-F1E1-4F6C-8926-0DCCF8B3BBCE}.Release|Any CPU.Build.0 = Release|Any CPU
80 | {84733491-76A1-41D9-8D94-2FDC3E8D8F17}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
81 | {84733491-76A1-41D9-8D94-2FDC3E8D8F17}.Debug|Any CPU.Build.0 = Debug|Any CPU
82 | {84733491-76A1-41D9-8D94-2FDC3E8D8F17}.Release|Any CPU.ActiveCfg = Release|Any CPU
83 | {84733491-76A1-41D9-8D94-2FDC3E8D8F17}.Release|Any CPU.Build.0 = Release|Any CPU
84 | {BA6B2B02-E20C-4E1C-96E9-54BFFAFA9704}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
85 | {BA6B2B02-E20C-4E1C-96E9-54BFFAFA9704}.Debug|Any CPU.Build.0 = Debug|Any CPU
86 | {BA6B2B02-E20C-4E1C-96E9-54BFFAFA9704}.Release|Any CPU.ActiveCfg = Release|Any CPU
87 | {BA6B2B02-E20C-4E1C-96E9-54BFFAFA9704}.Release|Any CPU.Build.0 = Release|Any CPU
88 | {2AAFB4A6-51AC-4ED6-9866-574D2A323E7B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
89 | {2AAFB4A6-51AC-4ED6-9866-574D2A323E7B}.Debug|Any CPU.Build.0 = Debug|Any CPU
90 | {2AAFB4A6-51AC-4ED6-9866-574D2A323E7B}.Release|Any CPU.ActiveCfg = Release|Any CPU
91 | {2AAFB4A6-51AC-4ED6-9866-574D2A323E7B}.Release|Any CPU.Build.0 = Release|Any CPU
92 | {47A10ED5-CF64-4E8F-9E5D-8D4E9FC2D53E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
93 | {47A10ED5-CF64-4E8F-9E5D-8D4E9FC2D53E}.Debug|Any CPU.Build.0 = Debug|Any CPU
94 | {47A10ED5-CF64-4E8F-9E5D-8D4E9FC2D53E}.Release|Any CPU.ActiveCfg = Release|Any CPU
95 | {47A10ED5-CF64-4E8F-9E5D-8D4E9FC2D53E}.Release|Any CPU.Build.0 = Release|Any CPU
96 | EndGlobalSection
97 | GlobalSection(SolutionProperties) = preSolution
98 | HideSolutionNode = FALSE
99 | EndGlobalSection
100 | GlobalSection(NestedProjects) = preSolution
101 | {F5A4869E-5E00-430B-8BFA-E73F1FBEC75E} = {F609564E-8C33-4F72-9DC7-4E13D9D52CA3}
102 | {2ABB1A87-C12F-49F6-B673-5139B4F13606} = {F609564E-8C33-4F72-9DC7-4E13D9D52CA3}
103 | {F7B35304-7785-47D4-9239-64FADFB9CA5D} = {F64CC1CD-DA16-4E69-91B5-8CCA545A6544}
104 | {AD1F253B-2634-467C-BFA4-AD9319CA3AFF} = {71022FAB-B94F-49F7-B44A-ED52288F792D}
105 | {FF90BAD1-56E8-4351-8CDB-F62B7E6CAFE7} = {71022FAB-B94F-49F7-B44A-ED52288F792D}
106 | {3116E006-C9B8-4FA3-B61A-533AF18AE153} = {11A8E1B9-2B97-4D7C-B34A-C66FAFFF9015}
107 | {11A8E1B9-2B97-4D7C-B34A-C66FAFFF9015} = {CE1B7235-D02E-406B-A05E-BE1B0CFD96D1}
108 | {F64CC1CD-DA16-4E69-91B5-8CCA545A6544} = {CE1B7235-D02E-406B-A05E-BE1B0CFD96D1}
109 | {27374D26-BB48-4E01-9280-027CEF1BB1B8} = {F64CC1CD-DA16-4E69-91B5-8CCA545A6544}
110 | {F48B6F9A-F1E1-4F6C-8926-0DCCF8B3BBCE} = {11A8E1B9-2B97-4D7C-B34A-C66FAFFF9015}
111 | {84733491-76A1-41D9-8D94-2FDC3E8D8F17} = {CE2B18FD-E675-431A-8654-8FCA55485E99}
112 | {BA6B2B02-E20C-4E1C-96E9-54BFFAFA9704} = {CE2B18FD-E675-431A-8654-8FCA55485E99}
113 | {2AAFB4A6-51AC-4ED6-9866-574D2A323E7B} = {CE2B18FD-E675-431A-8654-8FCA55485E99}
114 | {47A10ED5-CF64-4E8F-9E5D-8D4E9FC2D53E} = {71022FAB-B94F-49F7-B44A-ED52288F792D}
115 | EndGlobalSection
116 | GlobalSection(ExtensibilityGlobals) = postSolution
117 | SolutionGuid = {1589379E-12F3-40CE-83E4-44A39591685D}
118 | EndGlobalSection
119 | EndGlobal
120 |
--------------------------------------------------------------------------------
/appveyor.yml:
--------------------------------------------------------------------------------
1 | version: 1.0.{build}
2 | image:
3 | - macOS
4 | branches:
5 | only:
6 | - main
7 | environment:
8 | my_sonartoken_encrypted:
9 | secure: zE4kj0NoeBd1XOBLkDjFZS5lQ//xT5CilUr6ie90FrfE58PkGC1mL1NHumRI3+91
10 | before_build:
11 | - dotnet restore ModularArch.sln
12 | - dotnet tool install -g dotnet-sonarscanner
13 | # AppVeyor does not decrypt the secure env vars for PR builds (this prevents someone from submitting PR with malicious build script displaying those variables). So when AppVeyor initiates a Sonar analysis it immediately fails with error "The format of the analysis property sonar.login= is invalid". The only solution is to prevent PR builds initiating Sonar analysis using powershell. See https://medium.com/@stef.heyenrath/how-to-fix-sonarcloud-issue-in-a-github-pr-when-using-appveyor-integration-8909b49406b4
14 | - dotnet sonarscanner begin /k:"Amitpnk_Modular-Architecture-ASP.NET-Core" /o:"amitpnk" /d:"sonar.host.url=https://sonarcloud.io" /d:"sonar.login=$env:my_sonartoken_encrypted"
15 | build:
16 | project: ModularArch.sln
17 | verbosity: minimal
18 | after_build:
19 | - dotnet sonarscanner end /d:"sonar.login=$env:my_sonartoken_encrypted"
20 | notifications:
21 | - provider: Email
22 | to:
23 | - amit.naik8103@gmail.com
24 | on_build_success: false
25 | on_build_failure: false
26 | on_build_status_changed: true
--------------------------------------------------------------------------------
/docs/.nojekyll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Amitpnk/Modular-Architecture-ASP.NET-Core/d91085a782a1cfd638fe43b7d6226f7e20b1fc55/docs/.nojekyll
--------------------------------------------------------------------------------
/docs/README.md:
--------------------------------------------------------------------------------
1 | [](https://github.com/Amitpnk/Modular-Architecture-ASP.NET-Core/actions/workflows/dotnet-core.yml)
2 | [](https://ci.appveyor.com/project/Amitpnk/modular-architecture-asp-net-core)
3 | [](https://sonarcloud.io/dashboard?id=Amitpnk_Modular-Architecture-ASP.NET-Core)
4 | [](https://sonarcloud.io/dashboard?id=Amitpnk_Modular-Architecture-ASP.NET-Core)
5 | [](https://sonarcloud.io/dashboard?id=Amitpnk_Modular-Architecture-ASP.NET-Core)
6 | [](https://sonarcloud.io/dashboard?id=Amitpnk_Modular-Architecture-ASP.NET-Core)
7 | [](https://sonarcloud.io/dashboard?id=Amitpnk_Modular-Architecture-ASP.NET-Core)
8 | [](https://sonarcloud.io/dashboard?id=Amitpnk_Modular-Architecture-ASP.NET-Core)
9 | [](https://sonarcloud.io/dashboard?id=Amitpnk_Modular-Architecture-ASP.NET-Core)
10 | [](https://sonarcloud.io/dashboard?id=Amitpnk_Modular-Architecture-ASP.NET-Core)
11 | [](https://sonarcloud.io/dashboard?id=Amitpnk_Modular-Architecture-ASP.NET-Core)
12 | [](https://sonarcloud.io/dashboard?id=Amitpnk_Modular-Architecture-ASP.NET-Core)
13 | [](https://www.codacy.com/gh/Amitpnk/Hexagonal-Architecture-ASP.NET-Core/dashboard?utm_source=github.com&utm_medium=referral&utm_content=Amitpnk/Hexagonal-Architecture-ASP.NET-Core&utm_campaign=Badge_Grade)
14 |
15 | # Modular-Architecture-ASP.NET-Core
16 |
17 | ## Modular Architecture
18 |
19 | Modular Architecture also sometime called as Modular Monilth Architecture
20 |
21 | ## About The Project
22 |
23 | Solution template which is built on Modular Architecture with all essential feature using .NET Core!
24 | s
25 | 
26 |
27 | ## Status
28 |
29 | Untick mark is yet to complete soon
30 |
31 | ## Technology stack
32 |
33 | * Architecture
34 | - [x] Hexagonal architecture
35 | - [x] Screaming architecture
36 | * Design Pattern
37 | - [x] CQRS design pattern
38 | - [ ] Decorator design pattern
39 | - [x] Mediator design pattern
40 | - [x] Repository design pattern
41 | - [ ] Unit of work
42 | * Backend
43 | - [x] Language: C#
44 | - [x] Framework: dotnet core 3.1, ASP.NET Core
45 | - [ ] Framework: dotnet core 5, ASP.NET Core
46 | * UI
47 | - [ ] Framework: React-Redux boiler plate
48 | - [ ] MVC Core
49 | - [ ] Blazor
50 | * Database
51 | - [x] MS SQL and Inmemory DB
52 | - [x] DB Connectivity : Entityframework Core - Code First
53 | * Cloud server
54 | - [ ] Azure (alternate is AWS)
55 | * Service
56 | - [x] Web API (Restful service)
57 | - [ ] gRPC
58 | - [x] Graphql
59 | * Feature
60 | - [x] Dataseeding
61 | - [x] Custom Exceptionn Handler
62 | - [x] Automapper
63 | - [x] Fluent validation
64 | - [x] Serilog
65 | - [x] Swagger UI
66 | - [x] Healthcheck UI
67 | - [x] Advanced Pagination
68 | - [x] InMemory caching
69 | - [x] API Versioning
70 | - [ ] User Auditing
71 | - [ ] Mailkit (Mail service)
72 | - [ ] Hangfire
73 | - [x] Miniprofiler
74 | - [ ] Enabling CORS
75 | * Authentication
76 | - [ ] Identity server 4
77 | - [ ] OAuth2
78 | - [ ] JWT Authentication
79 | * Monitoring tool
80 | - [x] Health check UI
81 | - [x] Miniprofiler
82 | - [ ] Kibana dashboard (alternate is Grafana)
83 | * Testing Strategy using the testing pyramid
84 | - [x] Unit testing (Nunit)
85 | - [x] Integration testing
86 | * CI/CD
87 | - [x] Task runner: .Net core and CircleCI
88 | - [x] Coverage report: Sonarcloud.io
89 | - [x] Quality report: Codacy
90 | - [ ] Docker image and Kubernate
91 | - [ ] Azure pipelins
92 | * Documentation
93 | - [x] Conventional commit - commit and commit message
94 |
95 | ## Give a Star! :star:
96 |
97 | If you like or are using this project to learn or start your solution, please give it a star. Thanks!
98 |
99 | ## Support This Project
100 |
101 | If you have found this project helpful, either as a library that you use or as a learning tool, please consider buying me a coffee:
102 |
103 |
104 |
105 | ## Licence Used
106 |
107 | [](https://github.com/Amitpnk/Clean-architecture-ASP.NET-Core/blob/develop/LICENSE)
108 |
109 | See the contents of the LICENSE file for details
110 |
111 | ## Contact
112 |
113 | Having any issues or troubles getting started? Drop a mail to amit.naik8103@gmail.com or [Raise a Bug or Feature Request](https://github.com/Amitpnk/Clean-architecture-ASP.NET-Core/issues/new). Always happy to help.
114 |
--------------------------------------------------------------------------------
/docs/Step1-initial.ps1:
--------------------------------------------------------------------------------
1 | cd..
2 | docsify init ./docs
--------------------------------------------------------------------------------
/docs/Step2-execute.ps1:
--------------------------------------------------------------------------------
1 | cd..
2 | docsify serve docs
--------------------------------------------------------------------------------
/docs/img/Modular-arch.drawio:
--------------------------------------------------------------------------------
1 | 7V1Xd6NKtv4153G8yOGRDJJABEkgvcxC5IwIQujX38KprdDdPqdtj+euUXu1RVGCYu9vfztUlfwXyhUnqXHrWK38IP8LgfzTXyj/F4JQOAL+nxrGpwaMxp4aoibxn5rgHw1Wcg6eG6Hn1j7xg/aiY1dVeZfUl41eVZaB1120uU1TDZfdwiq/vGvtRsFNg+W5+W2rnfhd/PJY0I92OUii+OXOMPR8pnBfOj83tLHrV8ObJlT4C+Waquqe3hUnLsgn2b3I5elz4k/Ovg6sCcruPR9w6GFEAhS1+1NVHc4d6mzRfz1r5+jm/fMDPw+2G18kAMZdT2/j4ORGVfkXytZBkxRBFzQ/WvWXJvBY7BAnXWDVrjd9bACwAG1xV+TgCAZv3bZ+0lSYnAIwODZM8pyr8qp5vCEahiHieaC97ZoqC96c8Yk9gRPgzO2zP4vjGDRdcHrT9CwLKajA8JoRdHk5Szzr5RmYMEk8EORT0/BD0/iLpuM3WkYJ0Jd6BtkzwKLXO/zQAXjzrIa/oRLsRgOBDyD5fFhWJfjFNlVf+pPwHiVaNV1cAS24+aKq6ufGNOi68dmg3L6rLpUQlD4zmcePS4IWMZmGykO/kvA0mF/Ktwlyt0uOl/ZzT0rPH9WrBNziVS8ohV3oBaGhy0u0Vd94wfOn3uL96kIITV4pmLy8UOc2UdDdXAiIxR3fdK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LNX0E19LheOZlC2yrJ6S/CCE5BckCO+M7yBzYqNoX1YzdNROImLpvikmVBYG2YRKUG52w9Vmeq9kUYlnEVOAYyTjbO+1od3UZCvLq3B97uob7vZXtuEQYjSMutnN0EfSH4OxnIumr1CDzCAUVEAjRN8e5BWwsQIPZAXMLqJkFB7LFR2atb87Wmcta2RhqPduPRr9opqLflD2v7MKZraastO/2C3Y4udrktTf7JmfB4HqforECi2tXQcX1OuBOapAj0dwaodi0fcXJUs+xUKqD+rpnbZmapRXFx7wCQlIVyharekllOu9jG6qr6/F8WNiE02uQzuAVSMFVQjkouOJQB6SdqlYIBG98yEQOVcCcGnQlstUuXnslzqxz9pAV0CSs44wveXLqvh+B7bBEWVfQQZJOeb4/4xyVyTQ6C5Yo6HCmHWQqY7BqOraKMRUv2Zm5xoUmm0VRNBVVp58PWZdxtSMPwZEH6nZhLXpvKpJ+wLFPKlD/eidtkUSN21XffUKfgF9n618WOsJ39yl/1oZani8RET+285V8wgXb13RzfmeVEf9j8VrzsuzrScSP68euZHx/perlElrwT5yG9LP1qDcLWl4/cPsnjp5mDi4mmf7hnNCv1t++1T/y1+VWBejeHMXNyuqhxR6a4GlPruI9rswEh0/vLnu9IPnfr0L+97S+Nsyr4d/TXroX9N1A7Q4gf7E05/KPT2D4Xegh1Os6+gvbpj5ko9FdAP69hVcXin+06vbSqq8Qg1AkLtxdNPWKpefdw6ARZ8EP9PD4fWkc9ECg06+/cNCbezwBPzYjV6303dbHS1z3pH9yYfLx0+D8nYvAV23TV6Re9MX5O/jL+n3QlAEQz+Mqr+kxm2fwve7P/DNA0b9fLnlvEhMFbuID5jHvQukd65M+dfoaAEfE2E+Yvr6hqruse42BYxC4BfLQuMUHcQh048Fw5JZDUOp1A94f7rKaUuDXv/P3tM/+xx9LRIX/Aw==
--------------------------------------------------------------------------------
/docs/img/Modular-arch.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Amitpnk/Modular-Architecture-ASP.NET-Core/d91085a782a1cfd638fe43b7d6226f7e20b1fc55/docs/img/Modular-arch.png
--------------------------------------------------------------------------------
/docs/img/Module1.drawio:
--------------------------------------------------------------------------------
1 | 3VhNc5swEP01HJsBBA4+1thtDu3JmalzVGANNIKlsrChv77CSHyEOK07bnFy8Wjf7kra9yRYbBA/LT9zmsdfMQRm2GZYGmRp2Lbn2vK3BqoGcOZOA0Q8CRvI6oB18hMUaCq0SELYDQIFIhNJPgQDzDIIxACjnONhGLZFNlw1pxGMgHVA2Rj9loQi1mWZHX4HSRTrlS1TeVKqgxWwi2mIhx5EVgbxOaJoRmnpA6u507w0eZ9OeNuNccjEnyQ8kWDtpPEPfr9xQ+9uc48z74OaZU9ZoQqWChayeNtcqG2LSnPBschCqKezDLI4xImAdU6D2nuQ4kssFilT7m3CmI8M+TGXbLcwCwKJ7wTHJ+h5wtv5oySNqPX2wAWUJ2u0WubkiQNMQfBKhugETbY6bZaj7EOnXRsT93SbKYyq4xK1U3eMyoEi9QyC7RHBhj1joiYip5kcR/W4Jd3XXrlYP+ANauF416YFOU+L5fvR4vm9IO7UWjjnabF6P1o8vxfTa+GNWIRQvgSViVzEGGFG2apDFx3PNS1dzBfEXLH7HYSo1BudFgKH3Eu2eLVR+UfjoTZuXG0uy75zWWmrTMQx7ebWVeZDz9Vl1YZOagqsq3pdNEkCFjyAV8hyVRNCeQTidw/+8SHgwKhI9sN9XFzR+aSKWn+rqH3Vip641v9HUd0Pv2lJrWuTlEwqqTWppJd57l6dpM6UkrqjrqbtYD5etlXxAni5VXn0XMe9UKtCTHfQqtj/sIWXZvctfPT1/lAgq18=
--------------------------------------------------------------------------------
/docs/img/Module1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Amitpnk/Modular-Architecture-ASP.NET-Core/d91085a782a1cfd638fe43b7d6226f7e20b1fc55/docs/img/Module1.png
--------------------------------------------------------------------------------
/docs/img/Module2.drawio:
--------------------------------------------------------------------------------
1 | 3VjbcpswEP0aHtMBBA5+rLGT9DaTGWemTt9kWAONQEQWMc7XVwSJi7E9dsctIS8e7dmV0J7V0WI05Mb5LcNp+IP6QDRT93MNTTXTdGxT/BbAtgSssVUCAYv8EjJqYB69ggR1iWaRD+tWIKeU8Chtgx5NEvB4C8OM0U07bEVJ+6kpDqADzD1MuujPyOehSkuv8TuIglA92dClJ8YqWALrEPt004DQTEMuo5SXozh3gRTcKV7KeTcHvNXGGCT8lAlPyJtbcfjMHha279wtHujIuZKrvGCSyYRFBTORvKlP5Lb5VnHBaJb4UCxnaGiyCSMO8xR7hXcjii+wkMdEulcRIS4llL3NRasVjDxP4GvO6BM0PP71eClIQ5NuQmp3wDjkDUgmeAs0Bs62IkR5FdnytBmWtDd17aqYsFG3kcSwPC5BtXTNqBhIUs8g2OwQrJkjwgsiUpyIcVCMK9Jd5RUPawYMsBaW02Mt0PpbMH0ef72/iX/d23jimV9er1CHRfCF2KVJGQ9pQBNMZjU6qXkuaKljvlOaSnZ/A+dbeXPhjNM294JAtl3I+W/GY2F8spU5zZvO6VZZecQXdaSwHtWKYlxPKgw1p8yvSOrgHSGhNc2YB0fOreSKYxYAP8LpgTPAgGAevbT3cXFxofPENf044tq96JDdt7isXsVlDEpc1hDEZZ0nrtnHEddu5/qv4tpbC2eYneu6qS79BHX9jZjsrpiOvYntCLgvdY2HeV2a76miRl8V3XtZm31U9IJNaQ/r768p2Z2mVDWgzwPsNEi3W53G7P0/UveDgEsZFGvK9r5kVesHP8Jc0HJR3h0P9vO+dGzLrnnvkLynFCfzbqF/x7sw6488b77GlzI0+wM=
--------------------------------------------------------------------------------
/docs/img/Module2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Amitpnk/Modular-Architecture-ASP.NET-Core/d91085a782a1cfd638fe43b7d6226f7e20b1fc55/docs/img/Module2.png
--------------------------------------------------------------------------------
/docs/img/SolutionExplorer.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Amitpnk/Modular-Architecture-ASP.NET-Core/d91085a782a1cfd638fe43b7d6226f7e20b1fc55/docs/img/SolutionExplorer.png
--------------------------------------------------------------------------------
/docs/img/logo.drawio:
--------------------------------------------------------------------------------
1 | 7ZVNj5swEIZ/DcdGGENCjg2bTSs12kjZtuqpcsABq4ahjrOB/vqOgx0g2UjdY6WVEPI888F4eA0eTcpmpVhdrCHj0gv8rPHogxcEcRTg3YC2A+E87ECuRNYh0oOt+MMt9C09iowfRoEaQGpRj2EKVcVTPWJMKTiNw/Ygx0+tWc5vwDZl8pZ+F5ku3Lb8nn/iIi/ck4lvPSVzwRYcCpbBaYDo0qOJAtDdqmwSLs3s3Fy6vMc73ktjilf6XxK+bsIfxebnE1l9e/483a5/t/nmA+2qvDB5tBu2zerWTeCFKy1wIF/YjssNHIQWUKFrB1pD6dGFC/goRW4cGmqkhS4lGgSXuPPaFCub3GhksmMHkU5qkG1uKi3MKgFQ2fldRQu8/EkQeUHiexG2kJzBbAyIsSbRIGA+71BwnUQGILgCNyl9Wby63qSoTPs+mnshZQIS1Hk2NGM83qdmi1rBLz7wTNOY7/YXj9NOiMSOHKfGm7vvklwUgieLQ8m1ajHEJtCpFZU9VcTZp16jJLasGOrTqZHZc5FfavfSwYVVzxuUFL4r6b9U0jwaKymObpVEXlHS7O1CQrP/3J19g38GXf4F
--------------------------------------------------------------------------------
/docs/img/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Amitpnk/Modular-Architecture-ASP.NET-Core/d91085a782a1cfd638fe43b7d6226f7e20b1fc55/docs/img/logo.png
--------------------------------------------------------------------------------
/docs/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Document
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/docs/plans:
--------------------------------------------------------------------------------
1 | Phase 1
2 |
3 | WebAPI
4 | Code review + discussion + code refactor
5 | (BaseController + naming convention - port/adapter + Controller in
6 | Connecting to inmemory db
7 | Asp.net core features
8 |
9 | Phase 2
10 |
11 | Project template (dotnet core template/VSIX)
12 | SG Standard - Swagger, Authentication
13 | Integrate to App generator
14 |
15 | Phase 3
16 |
17 | Monitoring
18 | Logging
19 |
20 | Phase 4
21 |
22 | gRPC
23 | and other
--------------------------------------------------------------------------------
/script.ps1.txt:
--------------------------------------------------------------------------------
1 | Installation of dotnet template
2 |
3 | Step 1:
4 | dotnet new --install
5 |
6 | example 1:
7 | dotnet new --install D:\GitRepo\Hexagonal-Architecture-ASP.NET-Core\src
8 | example 2:
9 | (if project is in local path)
10 | dotnet new --install ./
11 | example 3:
12 | dotnet new --install ./src/
13 |
14 | Step 2:
15 | (redirect to different folder and check folder is empty)
16 | ls
17 |
18 | Step 3:
19 | dotnet new HexaArch -o
20 |
21 | dotnet new HexaArch -o Xone.Tau
22 | cd Xone.Tau
23 |
24 |
25 | Database migration
26 |
27 | add-migration Initial-commit-Application -Context ApplicationDbContext -o Migrations/Application
28 | update-database -Context ApplicationDbContext
29 |
--------------------------------------------------------------------------------
/src/.template.config/template.json:
--------------------------------------------------------------------------------
1 | {
2 | "author": "Amit Naik",
3 | "classifications": [
4 | "Web"
5 | ],
6 | "description": "Complete solution template which is built on Hexagonal Architecture with all essential feature, best practice, testing Strategy using the testing pyramid and documentation using .NET Core!",
7 | "name": "Hexagonal architecture template",
8 | "identity": "MyProject.StarterWeb",
9 | "tags": {
10 | "language": "C#"
11 | },
12 | "shortName": "HexaArch",
13 | "sourceName": "HA",
14 | "preferNameDirectory": "true"
15 | }
--------------------------------------------------------------------------------
/src/HA.Adapter.DealModule.Unit.Test/EventHandlers/CreateDealCommandHandlerTest.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using HA.Adapter.DealModule.Commands;
3 | using HA.Adapter.DealModule.EventHandlers;
4 | using HA.Application.Contract;
5 | using HA.Domain.Entities;
6 | using Moq;
7 | using NUnit.Framework;
8 | using System;
9 | using System.Threading;
10 | using System.Threading.Tasks;
11 |
12 | namespace HA.Adapter.DealModule.Unit.Test.EventHandlers
13 | {
14 | public class CreateDealCommandHandlerTest
15 | {
16 | [Test]
17 | public void Handle_CheckCompletionStatus_ShouldCreateCustomer()
18 | {
19 | // Arrange
20 | var genericRepositoryMock = new Mock>();
21 | var mapperMock = new Mock();
22 | var createDealCommand = new CreateDealCommand { Name = "IRD", Description = "IRD 123" };
23 | var createDealCommandHandler = new CreateDealCommandHandler(genericRepositoryMock.Object, mapperMock.Object);
24 |
25 | // Act
26 | var result = createDealCommandHandler.Handle(createDealCommand, new CancellationToken());
27 |
28 | // Assert
29 | Assert.AreEqual(Task.CompletedTask.Status, result.Status);
30 | }
31 |
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/HA.Adapter.DealModule.Unit.Test/HA.Module.Deal.Unit.Test.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp3.1
5 |
6 | false
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/src/HA.Adapter.DealModule/Commands/CreateDealCommand.cs:
--------------------------------------------------------------------------------
1 | using HA.Adapter.DealModule.ViewModel;
2 | using MediatR;
3 |
4 | namespace HA.Adapter.DealModule.Commands
5 | {
6 | public class CreateDealCommand : IRequest
7 | {
8 | public string Name { get; set; }
9 | public string Description { get; set; }
10 | }
11 | }
12 |
13 |
--------------------------------------------------------------------------------
/src/HA.Adapter.DealModule/Commands/DeleteDealCommand.cs:
--------------------------------------------------------------------------------
1 | using MediatR;
2 | using System;
3 |
4 | namespace HA.Adapter.DealModule.Commands
5 | {
6 | public class DeleteDealCommand : IRequest
7 | {
8 | public Guid DealId { get; set; }
9 |
10 | public DeleteDealCommand(Guid id)
11 | {
12 | DealId = id;
13 | }
14 |
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/HA.Adapter.DealModule/Commands/UpdateDealCommand.cs:
--------------------------------------------------------------------------------
1 | using HA.Adapter.DealModule.ViewModel;
2 | using MediatR;
3 | using System;
4 |
5 | namespace HA.Adapter.DealModule.Commands
6 | {
7 | public class UpdateDealCommand : IRequest
8 | {
9 | public Guid Id { get; set; }
10 | public string Name { get; set; }
11 | public string Description { get; set; }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/HA.Adapter.DealModule/Controllers/v1/DealController.cs:
--------------------------------------------------------------------------------
1 | using HA.Adapter.DealModule.Commands;
2 | using HA.Adapter.DealModule.Queries;
3 | using HA.Adapter.DealModule.ViewModel;
4 | using HA.Application.Controllers;
5 | using HA.Domain.Services;
6 | using Microsoft.AspNetCore.Http;
7 | using Microsoft.AspNetCore.Mvc;
8 | using System;
9 | using System.Text.Json;
10 | using System.Threading.Tasks;
11 |
12 | namespace HA.Adapter.DealModule.Controllers.v1
13 | {
14 | public class DealController : BaseController
15 | {
16 | [HttpGet]
17 | public async Task GetAll([FromQuery] QueryStringParameters queryStringParameters)
18 | {
19 | var vm = await Mediator.Send(new GetAllDealsQuery(queryStringParameters.PageNumber, queryStringParameters.PageSize));
20 |
21 | var paginationMetadata = new
22 | {
23 | totalCount = vm.TotalCount,
24 | pageSize = vm.PageSize,
25 | currentPage = vm.CurrentPage,
26 | totalPages = vm.TotalPages
27 | };
28 |
29 | Response.Headers.Add("X-Pagination",
30 | JsonSerializer.Serialize(paginationMetadata));
31 |
32 | return Ok(vm.Items);
33 | }
34 |
35 | [HttpGet("{id}")]
36 | [ProducesResponseType(StatusCodes.Status200OK)]
37 | [ProducesResponseType(StatusCodes.Status404NotFound)]
38 | public async Task> Get(Guid id)
39 | {
40 | var vm = await Mediator.Send(new GetDealByIdQuery(id));
41 | return Ok(vm);
42 | }
43 |
44 | [HttpPost]
45 | [ProducesResponseType(StatusCodes.Status201Created)]
46 | [ProducesDefaultResponseType]
47 | public async Task> Create([FromBody] CreateDealCommand command)
48 | {
49 | var vm = await Mediator.Send(command);
50 | return Ok(vm);
51 | }
52 |
53 | [HttpPut("{id}")]
54 | [ProducesResponseType(StatusCodes.Status200OK)]
55 | [ProducesResponseType(StatusCodes.Status404NotFound)]
56 | public async Task Update([FromBody] UpdateDealCommand command)
57 | {
58 | var vm = await Mediator.Send(command);
59 | return Ok(vm);
60 | }
61 |
62 | [HttpDelete("{id}")]
63 | [ProducesResponseType(StatusCodes.Status204NoContent)]
64 | [ProducesResponseType(StatusCodes.Status404NotFound)]
65 | public async Task Delete(Guid id)
66 | {
67 | await Mediator.Send(new DeleteDealCommand(id));
68 | return NoContent();
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/src/HA.Adapter.DealModule/Controllers/v2/ValuesController.cs:
--------------------------------------------------------------------------------
1 | using HA.Application.Controllers;
2 | using Microsoft.AspNetCore.Mvc;
3 | using System.Collections.Generic;
4 |
5 | namespace HA.Adapter.DealModule.Controllers.v2
6 | {
7 | [ApiVersion("2")]
8 | public class ValuesController : BaseController
9 | {
10 | [HttpGet]
11 | public IEnumerable Get()
12 | {
13 | return new[] { "value1", "value2" };
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/HA.Adapter.DealModule/DealModuleExtensions.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using FluentValidation;
3 | using MediatR;
4 | using Microsoft.Extensions.DependencyInjection;
5 | using System.Reflection;
6 |
7 | namespace HA.Adapter.DealModule
8 | {
9 | public static class DealModuleExtensions
10 | {
11 | public static void AddDealModule(this IServiceCollection serviceCollection)
12 | {
13 | serviceCollection.AddMediatR(Assembly.GetExecutingAssembly());
14 | serviceCollection.AddValidatorsFromAssembly(Assembly.GetExecutingAssembly());
15 | serviceCollection.AddAutoMapper(Assembly.GetExecutingAssembly());
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/HA.Adapter.DealModule/EventHandlers/CreateDealCommandHandler.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using HA.Adapter.DealModule.Commands;
3 | using HA.Adapter.DealModule.ViewModel;
4 | using HA.Application.Contract;
5 | using HA.Application.Exceptions;
6 | using HA.Domain.Entities;
7 | using MediatR;
8 | using System;
9 | using System.Threading;
10 | using System.Threading.Tasks;
11 |
12 | namespace HA.Adapter.DealModule.EventHandlers
13 | {
14 | public class CreateDealCommandHandler : IRequestHandler
15 | {
16 | private readonly IGenericRepositoryAsync _genericRepository;
17 | private readonly IMapper _mapper;
18 | public CreateDealCommandHandler(IGenericRepositoryAsync genericRepository, IMapper mapper)
19 | {
20 | _genericRepository = genericRepository;
21 | _mapper = mapper;
22 | }
23 | public async Task Handle(CreateDealCommand request, CancellationToken cancellationToken)
24 | {
25 | if (request == null)
26 | {
27 | throw new BadRequestException("Null exception");
28 | }
29 |
30 | var entity = new Deal
31 | {
32 | Id = Guid.NewGuid(),
33 | Name = request.Name,
34 | Description = request.Description,
35 | };
36 |
37 | await _genericRepository.AddAsync(entity);
38 | _genericRepository.SaveChanges();
39 |
40 | return _mapper.Map(entity);
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/HA.Adapter.DealModule/EventHandlers/DeleteDealCommandHandler.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using HA.Adapter.DealModule.Commands;
3 | using HA.Application.Contract;
4 | using HA.Application.Exceptions;
5 | using HA.Domain.Entities;
6 | using MediatR;
7 | using System;
8 | using System.Threading;
9 | using System.Threading.Tasks;
10 |
11 | namespace HA.Adapter.DealModule.EventHandlers
12 | {
13 | public class DeleteDealCommandHandler : IRequestHandler
14 | {
15 | private readonly IGenericRepositoryAsync _genericRepository;
16 | private readonly IMapper _mapper;
17 | public DeleteDealCommandHandler(IGenericRepositoryAsync genericRepository, IMapper mapper)
18 | {
19 | _genericRepository = genericRepository;
20 | _mapper = mapper;
21 | }
22 |
23 | public async Task Handle(DeleteDealCommand request, CancellationToken cancellationToken)
24 | {
25 | if (request == null)
26 | {
27 | throw new BadRequestException("Null exception");
28 | }
29 |
30 | var deal = await _genericRepository.GetByIdAsync(request.DealId);
31 |
32 | if (deal == null)
33 | {
34 | throw new NotFoundException(nameof(Deal), request.DealId);
35 | }
36 |
37 | await _genericRepository.DeleteAsync(request.DealId);
38 | _genericRepository.SaveChanges();
39 |
40 | return Unit.Value;
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/HA.Adapter.DealModule/EventHandlers/UpdateDealCommandHandler.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using HA.Adapter.DealModule.Commands;
3 | using HA.Adapter.DealModule.ViewModel;
4 | using HA.Application.Contract;
5 | using HA.Application.Exceptions;
6 | using HA.Domain.Entities;
7 | using MediatR;
8 | using System;
9 | using System.Threading;
10 | using System.Threading.Tasks;
11 |
12 | namespace HA.Adapter.DealModule.EventHandlers
13 | {
14 | public class UpdateDealCommandHandler : IRequestHandler
15 | {
16 | private readonly IGenericRepositoryAsync _genericRepository;
17 | private readonly IMapper _mapper;
18 | public UpdateDealCommandHandler(IGenericRepositoryAsync genericRepository, IMapper mapper)
19 | {
20 | _genericRepository = genericRepository;
21 | _mapper = mapper;
22 | }
23 | public async Task Handle(UpdateDealCommand request, CancellationToken cancellationToken)
24 | {
25 | if (request == null)
26 | {
27 | throw new BadRequestException("Null exception");
28 | }
29 |
30 | var entity = new Deal
31 | {
32 | Id = request.Id,
33 | Description = request.Description,
34 | Name = request.Name
35 | };
36 |
37 | var card = await _genericRepository.GetByIdAsync(request.Id);
38 | if (card == null)
39 | {
40 | throw new NotFoundException(nameof(Deal), request.Id);
41 | }
42 |
43 | await _genericRepository.UpdateAsync(entity);
44 | _genericRepository.SaveChanges();
45 |
46 | return _mapper.Map(entity);
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/HA.Adapter.DealModule/HA.Module.Deal.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp3.1
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/src/HA.Adapter.DealModule/Mapping/DealMapping.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using HA.Adapter.DealModule.ViewModel;
3 | using HA.Domain.Entities;
4 |
5 | namespace HA.Adapter.DealModule.Mapping
6 | {
7 | public class DealMapping : Profile
8 | {
9 | public DealMapping()
10 | {
11 | CreateMap();
12 | }
13 |
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/HA.Adapter.DealModule/Queries/GetAllDealsQuery.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using HA.Adapter.DealModule.ViewModel;
3 | using HA.Application.Contract;
4 | using HA.Application.Exceptions;
5 | using HA.Domain.Entities;
6 | using HA.Domain.Services;
7 | using MediatR;
8 | using System;
9 | using System.Collections.Generic;
10 | using System.Threading;
11 | using System.Threading.Tasks;
12 |
13 | namespace HA.Adapter.DealModule.Queries
14 | {
15 | public class GetAllDealsQuery : IRequest>
16 | {
17 | public int PageNumber { get; set; }
18 | public int PageSize { get; set; }
19 | public GetAllDealsQuery(int pageNumber, int pageSize)
20 | {
21 | PageNumber = pageNumber;
22 | PageSize = pageSize;
23 | }
24 | }
25 | public class GetAllDealHandler : IRequestHandler>
26 | {
27 | private readonly IGenericRepositoryAsync _genericRepository;
28 | private readonly IMapper _mapper;
29 |
30 | public GetAllDealHandler(IGenericRepositoryAsync genericRepository, IMapper mapper)
31 | {
32 | _genericRepository = genericRepository;
33 | _mapper = mapper;
34 | }
35 |
36 | public async Task> Handle(GetAllDealsQuery request, CancellationToken cancellationToken)
37 | {
38 | if (request == null)
39 | {
40 | throw new BadRequestException("Null exception");
41 | }
42 |
43 | var DealsList = await _genericRepository.GetPagedReponseAsync(request.PageNumber, request.PageSize);
44 | var DealsListVm = _mapper.Map>(DealsList);
45 | return new PagedResponse(DealsListVm, DealsList.TotalCount, request.PageNumber, request.PageSize);
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/HA.Adapter.DealModule/Queries/GetDealByIdQuery.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using HA.Adapter.DealModule.ViewModel;
3 | using HA.Application.Contract;
4 | using HA.Application.Exceptions;
5 | using HA.Domain.Entities;
6 | using MediatR;
7 | using System;
8 | using System.Threading;
9 | using System.Threading.Tasks;
10 |
11 | namespace HA.Adapter.DealModule.Queries
12 | {
13 | public class GetDealByIdQuery : IRequest
14 | {
15 | public Guid DealId { get; set; }
16 | public GetDealByIdQuery(Guid id)
17 | {
18 | DealId = id;
19 | }
20 | }
21 |
22 | public class GetDealByIdHandler : IRequestHandler
23 | {
24 | private readonly IGenericRepositoryAsync _genericRepository;
25 | private readonly IMapper _mapper;
26 |
27 | public GetDealByIdHandler(IGenericRepositoryAsync genericRepository, IMapper mapper)
28 | {
29 | _genericRepository = genericRepository;
30 | _mapper = mapper;
31 | }
32 |
33 | public async Task Handle(GetDealByIdQuery request, CancellationToken cancellationToken)
34 | {
35 | var entity = await _genericRepository.GetByIdAsync(request.DealId);
36 | if (entity == null)
37 | {
38 | throw new NotFoundException(nameof(Deal), request.DealId);
39 | }
40 | return _mapper.Map(entity);
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/HA.Adapter.DealModule/Validation/CreateDealCommandValidator.cs:
--------------------------------------------------------------------------------
1 | using FluentValidation;
2 | using HA.Adapter.DealModule.Commands;
3 |
4 | namespace HA.Adapter.DealModule.Validation
5 | {
6 | public class CreateDealCommandValidator : AbstractValidator
7 | {
8 | private const int maxLength = 50;
9 | public CreateDealCommandValidator()
10 | {
11 | RuleFor(x => x.Description).NotEmpty();
12 | RuleFor(x => x.Name).NotEmpty()
13 | .MaximumLength(maxLength);
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/HA.Adapter.DealModule/Validation/DeleteDealCommandValidator.cs:
--------------------------------------------------------------------------------
1 | using FluentValidation;
2 | using HA.Adapter.DealModule.Commands;
3 |
4 | namespace HA.Adapter.DealModule.Validation
5 | {
6 | public class DeleteDealCommandValidator : AbstractValidator
7 | {
8 | public DeleteDealCommandValidator()
9 | {
10 | RuleFor(v => v.DealId).NotEmpty();
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/HA.Adapter.DealModule/Validation/UpdateDealCommandValidator.cs:
--------------------------------------------------------------------------------
1 | using FluentValidation;
2 | using HA.Adapter.DealModule.Commands;
3 |
4 | namespace HA.Adapter.DealModule.Validation
5 | {
6 | public class UpdateDealCommandValidator : AbstractValidator
7 | {
8 | public UpdateDealCommandValidator()
9 | {
10 | RuleFor(x => x.Id);
11 | RuleFor(x => x.Name);
12 | RuleFor(x => x.Description).NotEmpty();
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/HA.Adapter.DealModule/ViewModel/DealViewModel.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using HA.Application.Contract;
3 | using HA.Domain.Entities;
4 | using System;
5 |
6 | namespace HA.Adapter.DealModule.ViewModel
7 | {
8 | public class DealViewModel : IMapFrom
9 | {
10 | public Guid Id { get; set; }
11 | public string Name { get; set; }
12 | public string Description { get; set; }
13 | public void Mapping(Profile profile)
14 | {
15 | profile.CreateMap()
16 | .ForMember(destination => destination.Id, source => source.MapFrom(source => source.Id));
17 | }
18 |
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/HA.Adapter.Persistence.Unit.Test/Common/ApplicationDbContextFactory.cs:
--------------------------------------------------------------------------------
1 | using HA.Adapter.Persistence.Context;
2 | using HA.Domain.Entities;
3 | using Microsoft.EntityFrameworkCore;
4 | using System;
5 | using System.Collections.Generic;
6 |
7 | namespace HA.Adapter.Persistence.Unit.Test.Common
8 | {
9 | public static class ApplicationDbContextFactory
10 | {
11 | public static List DealList()
12 | {
13 | return new List()
14 | {
15 | new Deal() {Id=Guid.NewGuid(), Name= "IRD", Description= "IRD Deal 123" },
16 | new Deal() {Id=Guid.NewGuid(), Name= "IRD", Description= "IRD Deal 456" },
17 | new Deal() {Id=Guid.NewGuid(), Name= "IRD", Description= "IRD Deal 789" },
18 | new Deal() {Id=Guid.NewGuid(), Name= "IRD", Description= "IRD Deal 147" },
19 | new Deal() {Id=Guid.NewGuid(), Name= "IRD", Description= "IRD Deal 258" }
20 | };
21 | }
22 | public static ApplicationDbContext Create()
23 | {
24 | var options = new DbContextOptionsBuilder()
25 | .UseInMemoryDatabase(Guid.NewGuid().ToString())
26 | .Options;
27 |
28 | var context = new ApplicationDbContext(options);
29 | context.Database.EnsureCreated();
30 | context.Deals.AddRange(DealList());
31 | context.SaveChanges();
32 | return context;
33 | }
34 |
35 | public static void Destroy(ApplicationDbContext context)
36 | {
37 | context.Database.EnsureDeleted();
38 | context.Dispose();
39 | }
40 | }
41 | }
--------------------------------------------------------------------------------
/src/HA.Adapter.Persistence.Unit.Test/Context/ApplicationDbContextTest.cs:
--------------------------------------------------------------------------------
1 | using HA.Adapter.Persistence.Unit.Test.Common;
2 | using HA.Domain.Entities;
3 | using Microsoft.EntityFrameworkCore;
4 | using NUnit.Framework;
5 | using System.Threading.Tasks;
6 |
7 | namespace HA.Adapter.Persistence.Unit.Test.Context
8 | {
9 | public class ApplicationDbContextTest
10 | {
11 | [Test]
12 | public void CanInsertDealIntoDatabase()
13 | {
14 | using var context = ApplicationDbContextFactory.Create();
15 | var deal = new Deal();
16 | context.Deals.Add(deal);
17 | Assert.AreEqual(EntityState.Added, context.Entry(deal).State);
18 | var result = context.SaveChangesAsync();
19 | Assert.AreEqual(1, result.Result);
20 | Assert.AreEqual(Task.CompletedTask.Status, result.Status);
21 | Assert.AreEqual(EntityState.Unchanged, context.Entry(deal).State);
22 | }
23 |
24 | [Test]
25 | public void CanUpdateDealIntoDatabase()
26 | {
27 | using var context = ApplicationDbContextFactory.Create();
28 | var deal = new Deal();
29 | context.Deals.Update(deal);
30 | Assert.AreEqual(EntityState.Added, context.Entry(deal).State);
31 | var result = context.SaveChangesAsync();
32 | Assert.AreEqual(1, result.Result);
33 | Assert.AreEqual(Task.CompletedTask.Status, result.Status);
34 | Assert.AreEqual(EntityState.Unchanged, context.Entry(deal).State);
35 | }
36 |
37 | [Test]
38 | public void CanDeleteDealIntoDatabase()
39 | {
40 | using var context = ApplicationDbContextFactory.Create();
41 | var deal = new Deal();
42 | context.Deals.Remove(deal);
43 | Assert.AreEqual(EntityState.Deleted, context.Entry(deal).State);
44 | }
45 |
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/HA.Adapter.Persistence.Unit.Test/HA.Module.Persistence.Unit.Test.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp3.1
5 |
6 | false
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/src/HA.Adapter.Persistence.Unit.Test/Repositories/GenericRepositoryAsyncTest.cs:
--------------------------------------------------------------------------------
1 | using HA.Adapter.Persistence.Repositories;
2 | using HA.Adapter.Persistence.Unit.Test.Common;
3 | using HA.Domain.Entities;
4 | using NUnit.Framework;
5 | using System;
6 | using System.Linq;
7 | using System.Threading.Tasks;
8 |
9 | namespace HA.Adapter.Persistence.Unit.Test.Repositories
10 | {
11 | public class GenericRepositoryAsyncTest
12 | {
13 |
14 | [Test, Order(1)]
15 | public async Task CheckGenenricRepositoryAddDeal()
16 | {
17 | using var context = ApplicationDbContextFactory.Create();
18 | var genericRepository = new GenericRepositoryAsync(context);
19 | await genericRepository.AddAsync(ApplicationDbContextFactory.DealList()[0]);
20 | var result = genericRepository.SaveChanges();
21 | Assert.IsTrue(result);
22 | }
23 |
24 | [Test, Order(2)]
25 | public async Task CheckGenenricRepositoryGetDeal()
26 | {
27 | using var context = ApplicationDbContextFactory.Create();
28 | var genericRepository = new GenericRepositoryAsync(context);
29 |
30 | var deal = new Deal() { Id = Guid.NewGuid(), Name = "IRD", Description = "IRD Deal XXX" };
31 |
32 | await genericRepository.AddAsync(deal);
33 | genericRepository.SaveChanges();
34 |
35 | var getAllDeal = await genericRepository.GetAllAsync();
36 |
37 | Assert.LessOrEqual(2, getAllDeal.Count());
38 | }
39 |
40 | [Test, Order(3)]
41 | public async Task CheckGenenricRepositoryGetByIdDeal()
42 | {
43 | using var context = ApplicationDbContextFactory.Create();
44 | var genericRepository = new GenericRepositoryAsync(context);
45 | var dealId = Guid.NewGuid();
46 | var deal = new Deal() { Id = dealId, Name = "IRD", Description = "IRD Deal XXX" };
47 | await genericRepository.AddAsync(deal);
48 | genericRepository.SaveChanges();
49 |
50 | var getdeal = genericRepository.GetByIdAsync(dealId);
51 | Assert.AreEqual(dealId, getdeal.Result.Id);
52 |
53 | }
54 |
55 | [Test, Order(4)]
56 | public async Task CheckGenenricRepositoryUpdateDeal()
57 | {
58 | using var context = ApplicationDbContextFactory.Create();
59 | var genericRepository = new GenericRepositoryAsync(context);
60 |
61 | var dealId = Guid.NewGuid();
62 | var deal = new Deal() { Id = dealId, Name = "IRD", Description = "IRD Deal XXX" };
63 | await genericRepository.AddAsync(deal);
64 | genericRepository.SaveChanges();
65 |
66 | await genericRepository.UpdateAsync(deal);
67 | Assert.IsTrue(genericRepository.SaveChanges());
68 |
69 | }
70 |
71 | [Test, Order(5)]
72 | public async Task CheckGenenricRepositoryDeleteDeal()
73 | {
74 | using var context = ApplicationDbContextFactory.Create();
75 | var genericRepository = new GenericRepositoryAsync(context);
76 |
77 | var dealId = Guid.NewGuid();
78 | var deal = new Deal() { Id = dealId, Name = "IRD", Description = "IRD Deal XXX" };
79 | await genericRepository.AddAsync(deal);
80 | genericRepository.SaveChanges();
81 |
82 | await genericRepository.DeleteAsync(dealId);
83 | Assert.IsTrue(genericRepository.SaveChanges());
84 | }
85 |
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/src/HA.Adapter.Persistence/Configurations/DealConfig.cs:
--------------------------------------------------------------------------------
1 | using HA.Domain.Entities;
2 | using Microsoft.EntityFrameworkCore;
3 | using Microsoft.EntityFrameworkCore.Metadata.Builders;
4 |
5 | namespace HA.Adapter.Persistence.Configurations
6 | {
7 | public class DealConfig : IEntityTypeConfiguration
8 | {
9 | public void Configure(EntityTypeBuilder builder)
10 | {
11 | builder.Property(p => p.Name).IsRequired().HasMaxLength(50);
12 | builder.Property(p => p.Description).IsRequired().HasMaxLength(100);
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/HA.Adapter.Persistence/Context/ApplicationDbContext.cs:
--------------------------------------------------------------------------------
1 | using HA.Domain.Entities;
2 | using Microsoft.EntityFrameworkCore;
3 | using System.Threading;
4 | using System.Threading.Tasks;
5 |
6 | namespace HA.Adapter.Persistence.Context
7 | {
8 | public class ApplicationDbContext : DbContext
9 | {
10 | public ApplicationDbContext()
11 | {
12 | }
13 | public ApplicationDbContext(DbContextOptions options) : base(options)
14 | {
15 | }
16 |
17 | public DbSet Deals { get; set; }
18 |
19 | protected override void OnModelCreating(ModelBuilder modelBuilder)
20 | {
21 | if (modelBuilder != null)
22 | {
23 | //Fluent API configurations
24 | modelBuilder.ApplyConfigurationsFromAssembly(typeof(ApplicationDbContext).Assembly);
25 | modelBuilder.Seed();
26 | }
27 | }
28 |
29 | public override Task SaveChangesAsync(CancellationToken cancellationToken = new CancellationToken())
30 | {
31 | return base.SaveChangesAsync(cancellationToken);
32 | }
33 |
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/HA.Adapter.Persistence/Context/ContextSeed.cs:
--------------------------------------------------------------------------------
1 | using HA.Domain.Entities;
2 | using Microsoft.EntityFrameworkCore;
3 | using System;
4 | using System.Collections.Generic;
5 |
6 | namespace HA.Adapter.Persistence.Context
7 | {
8 | public static class ContextSeed
9 | {
10 | public static void Seed(this ModelBuilder modelBuilder)
11 | {
12 | CreateDeals(modelBuilder);
13 | }
14 |
15 | private static void CreateDeals(ModelBuilder modelBuilder)
16 | {
17 | modelBuilder.Entity().HasData(DealList());
18 | }
19 |
20 | private static List DealList()
21 | {
22 | return new List
23 | {
24 | new Deal {Id=Guid.NewGuid(), Name= "IRD", Description= "IRD Deal 123" },
25 | new Deal {Id=Guid.NewGuid(), Name= "IRD", Description= "IRD Deal 456" },
26 | new Deal {Id=Guid.NewGuid(), Name= "IRD", Description= "IRD Deal 789" }
27 | };
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/HA.Adapter.Persistence/HA.Module.Persistence.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp3.1
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | all
13 | runtime; build; native; contentfiles; analyzers; buildtransitive
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/src/HA.Adapter.Persistence/PersistenceExtensions.cs:
--------------------------------------------------------------------------------
1 | using HA.Adapter.Persistence.Context;
2 | using HA.Adapter.Persistence.Repositories;
3 | using HA.Application.Contract;
4 | using HA.Domain.Services;
5 | using Microsoft.EntityFrameworkCore;
6 | using Microsoft.Extensions.Configuration;
7 | using Microsoft.Extensions.DependencyInjection;
8 |
9 | namespace HA.Adapter.Persistence
10 | {
11 | public static class PersistenceExtensions
12 | {
13 | public static void AddPersistence(this IServiceCollection serviceCollection,
14 | IConfiguration configuration,
15 | AppSettings appSettings)
16 | {
17 | if (configuration.GetValue("UseInMemoryDatabase"))
18 | {
19 | serviceCollection.AddDbContext(options =>
20 | options.UseInMemoryDatabase("HexaArchConnInMemoryDb"));
21 | }
22 | else
23 | {
24 | serviceCollection.AddDbContext(opt =>
25 | {
26 | opt.EnableSensitiveDataLogging(false);
27 | opt.UseSqlServer(appSettings.ConnectionStrings.HexaArchConn);
28 | });
29 | }
30 |
31 | serviceCollection.AddTransient(typeof(IGenericRepositoryAsync<,>), typeof(GenericRepositoryAsync<,>));
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/HA.Adapter.Persistence/Repositories/GenericRepositoryAsync.cs:
--------------------------------------------------------------------------------
1 | using HA.Adapter.Persistence.Context;
2 | using HA.Application.Contract;
3 | using HA.Domain.Common;
4 | using HA.Domain.Services;
5 | using Microsoft.EntityFrameworkCore;
6 | using System.Collections.Generic;
7 | using System.Linq;
8 | using System.Threading.Tasks;
9 |
10 | namespace HA.Adapter.Persistence.Repositories
11 | {
12 | public class GenericRepositoryAsync : IGenericRepositoryAsync
13 | where TEntity : AggregateRoot
14 | {
15 | private readonly ApplicationDbContext _dbContext;
16 | private readonly DbSet table;
17 |
18 | public GenericRepositoryAsync(ApplicationDbContext dbContext)
19 | {
20 | _dbContext = dbContext;
21 | table = _dbContext.Set();
22 | }
23 |
24 | public async Task AddAsync(TEntity obj)
25 | {
26 | await table.AddAsync(obj);
27 | }
28 |
29 | public async Task DeleteAsync(TKey id)
30 | {
31 | TEntity existing = await table.FindAsync(id);
32 | table.Remove(existing);
33 | }
34 | public async Task> GetAllAsync()
35 | {
36 | return await table.ToListAsync();
37 | }
38 | public async Task GetByIdAsync(TKey id)
39 | {
40 | return await table.FindAsync(id);
41 | }
42 |
43 | public async Task> GetPagedReponseAsync(int pageNumber, int pageSize)
44 | {
45 | var count = table.Count();
46 | var items = table.Skip((pageNumber - 1) * pageSize).Take(pageSize).ToList();
47 | return await Task.Run(() => new PagedList(items, count, pageNumber, pageSize));
48 | }
49 |
50 | public bool SaveChanges()
51 | {
52 | return _dbContext.SaveChanges() >= 0;
53 | }
54 |
55 | public async Task UpdateAsync(TEntity obj)
56 | {
57 | await Task.Run(() => table.Update(obj));
58 | }
59 | }
60 | }
--------------------------------------------------------------------------------
/src/HA.Application.Unit.Test/Exceptions.cs:
--------------------------------------------------------------------------------
1 | using HA.Application.Exceptions;
2 | using NUnit.Framework;
3 | using System;
4 |
5 | namespace HA.Application.Unit.Test
6 | {
7 | public class Exceptions
8 | {
9 | [TestCase("API exception")]
10 | public void CheckApiException(string ExceptionMessage)
11 | {
12 | Exception ex = new ApiException(ExceptionMessage, new Exception("Inner exception."));
13 | Exception ex2 = new ApiException(ExceptionMessage);
14 |
15 | Assert.AreEqual(ExceptionMessage, ex.Message.ToString());
16 | Assert.AreEqual(ExceptionMessage, ex2.Message.ToString());
17 | }
18 |
19 | [TestCase("Bad request exception")]
20 | public void CheckBadRequestException(string ExceptionMessage)
21 | {
22 | Exception ex = new BadRequestException(ExceptionMessage);
23 |
24 | Assert.AreEqual(ExceptionMessage, ex.Message.ToString());
25 | }
26 |
27 | [TestCase("card", 1, "Exception message")]
28 | [TestCase("card", "f09cedac-8c21-4f04-9ded-219bb57a07a4", "Exception message")]
29 | public void CheckDeleteFailureException(string name, object key, string message)
30 | {
31 |
32 | string ExceptionMessage = $"Deletion of entity \"{name}\" ({key}) failed. {message}";
33 | Exception ex = new DeleteFailureException(name, key, message);
34 |
35 | Assert.AreEqual(ExceptionMessage, ex.Message.ToString());
36 | }
37 |
38 | [TestCase("card", 1)]
39 | [TestCase("card", "f09cedac-8c21-4f04-9ded-219bb57a07a4")]
40 | public void CheckNotFoundException(string name, object key)
41 | {
42 |
43 | string ExceptionMessage = $"Entity \"{name}\" ({key}) was not found.";
44 | Exception ex = new NotFoundException(name, key);
45 |
46 | Assert.AreEqual(ExceptionMessage, ex.Message.ToString());
47 | }
48 |
49 | [TestCase("One or more validation failures have occurred.")]
50 | public void CheckValidationException(string ExceptionMessage)
51 | {
52 | var ex1 = new ValidationException();
53 | var ex2 = new ValidationException(ExceptionMessage);
54 |
55 |
56 | Assert.AreEqual(ExceptionMessage, ex1.Message.ToString());
57 | Assert.AreEqual(ExceptionMessage, ex2.Message.ToString());
58 | }
59 |
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/src/HA.Application.Unit.Test/HA.Application.Unit.Test.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp3.1
5 |
6 | false
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/src/HA.Application/ApplicationExtension.cs:
--------------------------------------------------------------------------------
1 | using HA.Application.Behaviours;
2 | using HA.Application.Middleware;
3 | using MediatR;
4 | using Microsoft.AspNetCore.Builder;
5 | using Microsoft.AspNetCore.Mvc;
6 | using Microsoft.Extensions.DependencyInjection;
7 |
8 | namespace HA.Application
9 | {
10 | public static class ApplicationExtensions
11 | {
12 | public static void AddApplication(this IServiceCollection serviceCollection)
13 | {
14 |
15 | serviceCollection.AddTransient(typeof(IPipelineBehavior<,>), typeof(ValidationBehavior<,>));
16 |
17 | serviceCollection.AddApiVersioning(config =>
18 | {
19 | config.DefaultApiVersion = new ApiVersion(1, 0);
20 | config.AssumeDefaultVersionWhenUnspecified = true;
21 | config.ReportApiVersions = true;
22 | });
23 | }
24 |
25 |
26 | public static void UseExceptionHandlerMiddleware(this IApplicationBuilder app)
27 | {
28 | app.UseMiddleware();
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/src/HA.Application/Behaviours/ValidationBehavior.cs:
--------------------------------------------------------------------------------
1 | using FluentValidation;
2 | using MediatR;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Threading;
6 | using System.Threading.Tasks;
7 |
8 | namespace HA.Application.Behaviours
9 | {
10 | public class ValidationBehavior : IPipelineBehavior
11 | where TRequest : IRequest
12 | {
13 | private readonly IEnumerable> _validators;
14 |
15 | public ValidationBehavior(IEnumerable> validators)
16 | {
17 | _validators = validators;
18 | }
19 |
20 | public async Task Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate next)
21 | {
22 | if (_validators.Any())
23 | {
24 | var context = new FluentValidation.ValidationContext(request);
25 | var validationResults = await Task.WhenAll(_validators.Select(v => v.ValidateAsync(context, cancellationToken)));
26 | var failures = validationResults.SelectMany(r => r.Errors).Where(f => f != null).ToList();
27 |
28 | if (failures.Any())
29 | {
30 | throw new ValidationException(failures);
31 | }
32 | }
33 | return await next();
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/HA.Application/Contract/IGenericRepositoryAsync.cs:
--------------------------------------------------------------------------------
1 | using HA.Domain.Common;
2 | using HA.Domain.Services;
3 | using System.Collections.Generic;
4 | using System.Threading.Tasks;
5 |
6 | namespace HA.Application.Contract
7 | {
8 | public interface IGenericRepositoryAsync
9 | where TEntity : AggregateRoot
10 | {
11 | Task> GetAllAsync();
12 | Task> GetPagedReponseAsync(int pageNumber, int pageSize);
13 | Task GetByIdAsync(TKey id);
14 | Task AddAsync(TEntity obj);
15 | Task UpdateAsync(TEntity obj);
16 | Task DeleteAsync(TKey id);
17 | bool SaveChanges();
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/HA.Application/Contract/IMapFrom.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 |
3 | namespace HA.Application.Contract
4 | {
5 | public interface IMapFrom
6 | {
7 | void Mapping(Profile profile) => profile.CreateMap(typeof(T), GetType());
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/src/HA.Application/Controllers/BaseController.cs:
--------------------------------------------------------------------------------
1 | using MediatR;
2 | using Microsoft.AspNetCore.Http;
3 | using Microsoft.AspNetCore.Mvc;
4 | using Microsoft.Extensions.DependencyInjection;
5 |
6 | namespace HA.Application.Controllers
7 | {
8 | [ApiController]
9 | [Route("api/v{version:apiVersion}/[controller]")]
10 | public class BaseController : ControllerBase
11 | {
12 | private IMediator _mediator;
13 | protected IMediator Mediator => _mediator ??= HttpContext.RequestServices.GetService();
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/HA.Application/Exceptions/ApiExceptions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using System.Runtime.Serialization;
4 |
5 | namespace HA.Application.Exceptions
6 | {
7 | [Serializable]
8 | public class ApiException : Exception
9 | {
10 | public ApiException(string message) : base(message) { }
11 |
12 | public ApiException(string message, params object[] args)
13 | : base(String.Format(CultureInfo.CurrentCulture, message, args))
14 | {
15 | }
16 |
17 | protected ApiException(SerializationInfo info, StreamingContext context)
18 | : base(info, context)
19 | {
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/HA.Application/Exceptions/BadRequestException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.Serialization;
3 |
4 | namespace HA.Application.Exceptions
5 | {
6 | [Serializable]
7 | public class BadRequestException : Exception
8 | {
9 | public BadRequestException(string message)
10 | : base(message)
11 | {
12 | }
13 |
14 | protected BadRequestException(SerializationInfo info, StreamingContext context)
15 | : base(info, context)
16 | {
17 | }
18 |
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/HA.Application/Exceptions/DeleteFailureException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.Serialization;
3 |
4 | namespace HA.Application.Exceptions
5 | {
6 | [Serializable]
7 | public class DeleteFailureException : Exception
8 | {
9 | public DeleteFailureException(string name, object key, string message)
10 | : base($"Deletion of entity \"{name}\" ({key}) failed. {message}")
11 | {
12 | }
13 |
14 | protected DeleteFailureException(SerializationInfo info, StreamingContext context)
15 | : base(info, context)
16 | {
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/HA.Application/Exceptions/NotFoundException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.Serialization;
3 |
4 | namespace HA.Application.Exceptions
5 | {
6 | [Serializable]
7 | public class NotFoundException : Exception
8 | {
9 | public NotFoundException(string name, object key)
10 | : base($"Entity \"{name}\" ({key}) was not found.")
11 | {
12 | }
13 |
14 | protected NotFoundException(SerializationInfo info, StreamingContext context)
15 | : base(info, context)
16 | {
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/HA.Application/Exceptions/ValidationException.cs:
--------------------------------------------------------------------------------
1 | using FluentValidation.Results;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Runtime.Serialization;
6 |
7 | namespace HA.Application.Exceptions
8 | {
9 | [Serializable]
10 | public class ValidationException : Exception
11 | {
12 | public ValidationException()
13 | : base("One or more validation failures have occurred.")
14 | {
15 | Failures = new Dictionary();
16 | }
17 | public ValidationException(string message) : base(message)
18 | {
19 | }
20 |
21 | public ValidationException(List failures)
22 | : this()
23 | {
24 | var propertyNames = failures
25 | .Select(e => e.PropertyName)
26 | .Distinct();
27 |
28 | foreach (var propertyName in propertyNames)
29 | {
30 | var propertyFailures = failures
31 | .Where(e => e.PropertyName == propertyName)
32 | .Select(e => e.ErrorMessage)
33 | .ToArray();
34 |
35 | Failures.Add(propertyName, propertyFailures);
36 | }
37 | }
38 |
39 | public IDictionary Failures { get; }
40 |
41 | protected ValidationException(SerializationInfo info, StreamingContext context)
42 | : base(info, context)
43 | {
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/HA.Application/HA.Application.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp3.1
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/src/HA.Application/Middleware/CustomExceptionHandlerMiddleware.cs:
--------------------------------------------------------------------------------
1 | using HA.Application.Exceptions;
2 | using Microsoft.AspNetCore.Http;
3 | using Microsoft.Extensions.Logging;
4 | using Newtonsoft.Json;
5 | using System;
6 | using System.Net;
7 | using System.Threading.Tasks;
8 |
9 | namespace HA.Application.Middleware
10 | {
11 | public class CustomExceptionHandlerMiddleware
12 | {
13 | private readonly RequestDelegate _next;
14 | private readonly ILogger _logger;
15 | public CustomExceptionHandlerMiddleware(RequestDelegate next,
16 | ILogger logger)
17 | {
18 | _next = next;
19 | _logger = logger;
20 | }
21 |
22 | public async Task InvokeAsync(HttpContext context)
23 | {
24 | try
25 | {
26 | await _next(context);
27 | }
28 | catch (Exception exceptionObj)
29 | {
30 | await HandleExceptionAsync(context, exceptionObj, _logger);
31 | }
32 | }
33 |
34 | private static Task HandleExceptionAsync(HttpContext context, Exception exception, ILogger logger)
35 | {
36 | int code;
37 | var result = exception.Message;
38 |
39 | switch (exception)
40 | {
41 | case ValidationException validationException:
42 | code = (int)HttpStatusCode.BadRequest;
43 | result = JsonConvert.SerializeObject(validationException.Failures);
44 | break;
45 | case BadRequestException badRequestException:
46 | code = (int)HttpStatusCode.BadRequest;
47 | result = badRequestException.Message;
48 | break;
49 | case DeleteFailureException deleteFailureException:
50 | code = (int)HttpStatusCode.BadRequest;
51 | result = deleteFailureException.Message;
52 | break;
53 | case NotFoundException _:
54 | code = (int)HttpStatusCode.NotFound;
55 | break;
56 | default:
57 | code = (int)HttpStatusCode.InternalServerError;
58 | break;
59 | }
60 |
61 | logger.LogError(result);
62 |
63 | context.Response.ContentType = "application/json";
64 | context.Response.StatusCode = code;
65 | return context.Response.WriteAsync(JsonConvert.SerializeObject(new { StatusCode = code, ErrorMessage = exception.Message }));
66 | }
67 | }
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/src/HA.DatabaseMigration/HA.DatabaseMigration.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp3.1
5 |
6 |
7 |
8 |
9 | all
10 | runtime; build; native; contentfiles; analyzers; buildtransitive
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/src/HA.DatabaseMigration/Program.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Hosting;
2 | using Microsoft.Extensions.Hosting;
3 |
4 | namespace HA.DatabaseMigration
5 | {
6 | public class Program
7 | {
8 | public static void Main(string[] args)
9 | {
10 | CreateHostBuilder(args).Build().Run();
11 | }
12 |
13 | public static IHostBuilder CreateHostBuilder(string[] args) =>
14 | Host.CreateDefaultBuilder(args)
15 | .ConfigureWebHostDefaults(webBuilder =>
16 | {
17 | webBuilder.UseStartup();
18 | });
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/HA.DatabaseMigration/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json.schemastore.org/launchsettings.json",
3 | "iisSettings": {
4 | "windowsAuthentication": false,
5 | "anonymousAuthentication": true,
6 | "iisExpress": {
7 | "applicationUrl": "http://localhost:63514",
8 | "sslPort": 44381
9 | }
10 | },
11 | "profiles": {
12 | "IIS Express": {
13 | "commandName": "IISExpress",
14 | "launchBrowser": true,
15 | "launchUrl": "weatherforecast",
16 | "environmentVariables": {
17 | "ASPNETCORE_ENVIRONMENT": "Development"
18 | }
19 | },
20 | "HA.DatabaseMigration": {
21 | "commandName": "Project",
22 | "launchBrowser": true,
23 | "launchUrl": "weatherforecast",
24 | "applicationUrl": "https://localhost:5001;http://localhost:5000",
25 | "environmentVariables": {
26 | "ASPNETCORE_ENVIRONMENT": "Development"
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/HA.DatabaseMigration/Startup.cs:
--------------------------------------------------------------------------------
1 | using HA.Adapter.Persistence;
2 | using HA.Domain.Services;
3 | using Microsoft.AspNetCore.Builder;
4 | using Microsoft.AspNetCore.Hosting;
5 | using Microsoft.Extensions.Configuration;
6 | using Microsoft.Extensions.DependencyInjection;
7 | using Microsoft.Extensions.Hosting;
8 |
9 | namespace HA.DatabaseMigration
10 | {
11 | public class Startup
12 | {
13 | public IConfiguration Configuration { get; }
14 | public AppSettings AppSettings { get; set; }
15 |
16 | public Startup(IConfiguration configuration)
17 | {
18 | Configuration = configuration;
19 |
20 | AppSettings = new AppSettings();
21 | Configuration.Bind(AppSettings);
22 | }
23 |
24 | public void ConfigureServices(IServiceCollection services)
25 | {
26 | services.AddPersistence(Configuration, AppSettings);
27 | }
28 |
29 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
30 | {
31 | if (env.IsDevelopment())
32 | {
33 | app.UseDeveloperExceptionPage();
34 | }
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/HA.DatabaseMigration/appsettings.Development.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft": "Warning",
6 | "Microsoft.Hosting.Lifetime": "Information"
7 | }
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/src/HA.DatabaseMigration/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "ConnectionStrings": {
3 | "HexaArchConn": "Data Source=(local)\\SQLexpress01;Initial Catalog=HexaDb;Integrated Security=True"
4 | }
5 | }
--------------------------------------------------------------------------------
/src/HA.Domain.Unit.Test/Entities/DealTest.cs:
--------------------------------------------------------------------------------
1 | using HA.Domain.Entities;
2 | using NUnit.Framework;
3 | using System;
4 |
5 | namespace HA.Domain.Unit.Test.Entities
6 | {
7 | public class GroupTest
8 | {
9 | private readonly Deal _deal;
10 | private readonly Guid Id = Guid.NewGuid();
11 | private const string Name = "Test";
12 | private const string Description = "Test Description";
13 |
14 | public GroupTest()
15 | {
16 | _deal = new Deal();
17 | }
18 |
19 | [Test]
20 | public void TestSetAndGetId()
21 | {
22 | _deal.Id = Id;
23 | Assert.That(_deal.Id, Is.EqualTo(Id));
24 | }
25 |
26 | [Test]
27 | public void TestSetAndGetName()
28 | {
29 | _deal.Name = Name;
30 | Assert.That(_deal.Name, Is.EqualTo(Name));
31 | }
32 |
33 | [Test]
34 | public void TestSetAndGetDescription()
35 | {
36 | _deal.Description = Description;
37 | Assert.That(_deal.Description, Is.EqualTo(Description));
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/HA.Domain.Unit.Test/HA.Domain.Unit.Test.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp3.1
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/HA.Domain.Unit.Test/Services/ApplicationDetailTest.cs:
--------------------------------------------------------------------------------
1 | using HA.WebAPI.ConfigurationOptions;
2 | using NUnit.Framework;
3 |
4 | namespace HA.Domain.Unit.Test.Services
5 | {
6 | public class ApplicationDetailTest
7 | {
8 | private readonly ApplicationDetail _applicationDetail;
9 | private const string ContactWebsite = "https://amitpnk.github.io/";
10 | private const string LicenseDetail = "https://opensource.org/licenses/MIT";
11 |
12 | public ApplicationDetailTest()
13 | {
14 | _applicationDetail = new ApplicationDetail();
15 | }
16 |
17 | [Test]
18 | public void TestSetAndGetContactWebsite()
19 | {
20 | _applicationDetail.ContactWebsite = ContactWebsite;
21 | Assert.That(_applicationDetail.ContactWebsite, Is.EqualTo(ContactWebsite));
22 | }
23 |
24 | [Test]
25 | public void TestSetAndGetLicenseDetail()
26 | {
27 | _applicationDetail.LicenseDetail = LicenseDetail;
28 | Assert.That(_applicationDetail.LicenseDetail, Is.EqualTo(LicenseDetail));
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/HA.Domain/Common/AggregateRoot.cs:
--------------------------------------------------------------------------------
1 | namespace HA.Domain.Common
2 | {
3 | public abstract class AggregateRoot : BaseEntity
4 | {
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/src/HA.Domain/Common/AuditLogEntry.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace HA.Domain.Common
4 | {
5 | public class AuditLogEntry : AggregateRoot
6 | {
7 | public Guid UserId { get; set; }
8 |
9 | public string Action { get; set; }
10 |
11 | public string ObjectId { get; set; }
12 |
13 | public string Log { get; set; }
14 |
15 | public DateTime CreatedDateTime { get; set; }
16 |
17 | public string LastModifiedBy { get; set; }
18 |
19 | public DateTime? LastModified { get; set; }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/HA.Domain/Common/BaseEntity.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel.DataAnnotations;
2 |
3 | namespace HA.Domain.Common
4 | {
5 | public abstract class BaseEntity : IHasKey
6 | {
7 | [Key]
8 | public TKey Id { get; set; }
9 |
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/HA.Domain/Common/IHasKey.cs:
--------------------------------------------------------------------------------
1 | namespace HA.Domain.Common
2 | {
3 | public interface IHasKey
4 | {
5 | T Id { get; set; }
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/src/HA.Domain/Entities/Deal.cs:
--------------------------------------------------------------------------------
1 | using HA.Domain.Common;
2 | using System;
3 |
4 | namespace HA.Domain.Entities
5 | {
6 | public class Deal : AggregateRoot
7 | {
8 | public string Name { get; set; }
9 | public string Description { get; set; }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/HA.Domain/HA.Domain.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp3.1
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/src/HA.Domain/Services/AppSettings.cs:
--------------------------------------------------------------------------------
1 | using HA.WebAPI.ConfigurationOptions;
2 |
3 | namespace HA.Domain.Services
4 | {
5 | public class AppSettings
6 | {
7 | public ConnectionStrings ConnectionStrings { get; set; }
8 | public ApplicationDetail ApplicationDetail { get; set; }
9 |
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/HA.Domain/Services/ApplicationDetail.cs:
--------------------------------------------------------------------------------
1 | namespace HA.WebAPI.ConfigurationOptions
2 | {
3 | public class ApplicationDetail
4 | {
5 | public string ContactWebsite { get; set; }
6 | public string LicenseDetail { get; set; }
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/src/HA.Domain/Services/ConnectionStrings.cs:
--------------------------------------------------------------------------------
1 | namespace HA.WebAPI.ConfigurationOptions
2 | {
3 | public class ConnectionStrings
4 | {
5 | public string HexaArchConn { get; set; }
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/src/HA.Domain/Services/DataShaper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Dynamic;
4 | using System.Linq;
5 | using System.Reflection;
6 |
7 | namespace HA.Domain.Services
8 | {
9 | public interface IDataShaper
10 | {
11 | IEnumerable ShapeData(IEnumerable entities, string fieldsString);
12 | ExpandoObject ShapeData(T entity, string fieldsString);
13 | }
14 |
15 | public class DataShaper : IDataShaper
16 | {
17 | public PropertyInfo[] Properties { get; set; }
18 |
19 | public DataShaper()
20 | {
21 | Properties = typeof(T).GetProperties(BindingFlags.Public | BindingFlags.Instance);
22 | }
23 |
24 | public IEnumerable ShapeData(IEnumerable entities, string fieldsString)
25 | {
26 | var requiredProperties = GetRequiredProperties(fieldsString);
27 |
28 | return FetchData(entities, requiredProperties);
29 | }
30 |
31 | public ExpandoObject ShapeData(T entity, string fieldsString)
32 | {
33 | var requiredProperties = GetRequiredProperties(fieldsString);
34 |
35 | return FetchDataForEntity(entity, requiredProperties);
36 | }
37 |
38 | private IEnumerable GetRequiredProperties(string fieldsString)
39 | {
40 | var requiredProperties = new List();
41 |
42 | if (!string.IsNullOrWhiteSpace(fieldsString))
43 | {
44 | var fields = fieldsString.Split(',', StringSplitOptions.RemoveEmptyEntries);
45 |
46 | foreach (var field in fields)
47 | {
48 | var property = Properties.FirstOrDefault(pi => pi.Name.Equals(field.Trim(), StringComparison.InvariantCultureIgnoreCase));
49 |
50 | if (property == null)
51 | continue;
52 |
53 | requiredProperties.Add(property);
54 | }
55 | }
56 | else
57 | {
58 | requiredProperties = Properties.ToList();
59 | }
60 |
61 | return requiredProperties;
62 | }
63 |
64 | private IEnumerable FetchData(IEnumerable entities, IEnumerable requiredProperties)
65 | {
66 | var shapedData = new List();
67 |
68 | foreach (var entity in entities)
69 | {
70 | var shapedObject = FetchDataForEntity(entity, requiredProperties);
71 | shapedData.Add(shapedObject);
72 | }
73 |
74 | return shapedData;
75 | }
76 |
77 | private ExpandoObject FetchDataForEntity(T entity, IEnumerable requiredProperties)
78 | {
79 | var shapedObject = new ExpandoObject();
80 |
81 | foreach (var property in requiredProperties)
82 | {
83 | var objectPropertyValue = property.GetValue(entity);
84 | shapedObject.TryAdd(property.Name, objectPropertyValue);
85 | }
86 |
87 | return shapedObject;
88 | }
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/src/HA.Domain/Services/PagedList.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace HA.Domain.Services
5 | {
6 | public class PagedList : List
7 | {
8 | public int CurrentPage { get; private set; }
9 | public int TotalPages { get; private set; }
10 | public int PageSize { get; private set; }
11 | public int TotalCount { get; private set; }
12 | public bool HasPrevious => (CurrentPage > 1);
13 | public bool HasNext => (CurrentPage < TotalPages);
14 |
15 | public PagedList(List items, int count, int pageNumber, int pageSize)
16 | {
17 | TotalCount = count;
18 | PageSize = pageSize;
19 | CurrentPage = pageNumber;
20 | TotalPages = (int)Math.Ceiling(count / (double)pageSize);
21 | AddRange(items);
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/HA.Domain/Services/PagedResponse.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace HA.Domain.Services
5 | {
6 | public class PagedResponse
7 | {
8 |
9 | public PagedResponse(List items, int count, int pageNumber, int pageSize)
10 | {
11 | Items = items;
12 | TotalCount = count;
13 | PageSize = pageSize;
14 | CurrentPage = pageNumber;
15 | TotalPages = (int)Math.Ceiling(count / (double)pageSize);
16 | }
17 |
18 | public int CurrentPage { get; private set; }
19 | public int TotalPages { get; private set; }
20 | public int PageSize { get; private set; }
21 | public int TotalCount { get; private set; }
22 | public bool HasPrevious => (CurrentPage > 1);
23 | public bool HasNext => (CurrentPage < TotalPages);
24 | public List Items { get; set; }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/HA.Domain/Services/QueryStringParameters.cs:
--------------------------------------------------------------------------------
1 | namespace HA.Domain.Services
2 | {
3 | public class QueryStringParameters
4 | {
5 | const int maxPageSize = 20;
6 | public int PageNumber { get; set; } = 1;
7 |
8 | private int _pageSize = 10;
9 | public int PageSize
10 | {
11 | get { return _pageSize; }
12 | set { _pageSize = (value > maxPageSize) ? maxPageSize : value; }
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/HA.GraphQL/GraphQL.postman_collection.json:
--------------------------------------------------------------------------------
1 | {
2 | "info": {
3 | "_postman_id": "392bbb54-bcf4-4f4a-b335-068ac48ef740",
4 | "name": "GraphQL",
5 | "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
6 | },
7 | "item": [
8 | {
9 | "name": "Get all via Post method",
10 | "request": {
11 | "method": "POST",
12 | "header": [],
13 | "body": {
14 | "mode": "raw",
15 | "raw": "{\r\n \"query\":\"{ deals { id name description }}\"\r\n}",
16 | "options": {
17 | "raw": {
18 | "language": "json"
19 | }
20 | }
21 | },
22 | "url": {
23 | "raw": "http://localhost:54736/graphql?Content-Type=application/json",
24 | "protocol": "http",
25 | "host": [
26 | "localhost"
27 | ],
28 | "port": "54736",
29 | "path": [
30 | "graphql"
31 | ],
32 | "query": [
33 | {
34 | "key": "Content-Type",
35 | "value": "application/json"
36 | }
37 | ]
38 | }
39 | },
40 | "response": []
41 | },
42 | {
43 | "name": "Get all via Get method",
44 | "request": {
45 | "method": "GET",
46 | "header": [],
47 | "url": {
48 | "raw": "http://localhost:54736/graphql?query={ deals { id name description }}",
49 | "protocol": "http",
50 | "host": [
51 | "localhost"
52 | ],
53 | "port": "54736",
54 | "path": [
55 | "graphql"
56 | ],
57 | "query": [
58 | {
59 | "key": "query",
60 | "value": "{ deals { id name description }}"
61 | }
62 | ]
63 | }
64 | },
65 | "response": []
66 | }
67 | ],
68 | "protocolProfileBehavior": {}
69 | }
--------------------------------------------------------------------------------
/src/HA.GraphQL/GraphQL/DealSchema.cs:
--------------------------------------------------------------------------------
1 | using GraphQL;
2 | using GraphQL.Types;
3 | using HA.GraphQL.Queries;
4 |
5 | namespace HA.GraphQL
6 | {
7 | public class DealSchema : Schema
8 | {
9 | public DealSchema(IDependencyResolver resolver) : base(resolver)
10 | {
11 | Query = resolver.Resolve();
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/HA.GraphQL/GraphQL/Queries/DealQuery.cs:
--------------------------------------------------------------------------------
1 | using GraphQL.Types;
2 | using HA.Application.Contract;
3 | using HA.Domain.Entities;
4 | using HA.GraphQL.Types;
5 | using System;
6 |
7 | namespace HA.GraphQL.Queries
8 | {
9 | public class DealQuery : ObjectGraphType
10 | {
11 | private readonly IGenericRepositoryAsync _genericRepository;
12 |
13 | public DealQuery(IGenericRepositoryAsync genericRepository)
14 | {
15 | _genericRepository = genericRepository;
16 | Name = "DealQuery";
17 | Field>(
18 | "deals",
19 | "Returns a list of Deal",
20 | resolve: context => _genericRepository.GetAllAsync());
21 |
22 | Field(
23 | "deal",
24 | "Returns a Single Deal",
25 | arguments: new QueryArguments(new QueryArgument> { Name = "id" }),
26 | resolve: context =>
27 | {
28 | var id = context.GetArgument("id");
29 | return _genericRepository.GetByIdAsync(id);
30 | }
31 | );
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/HA.GraphQL/GraphQL/Types/DealGraphType.cs:
--------------------------------------------------------------------------------
1 | using GraphQL.Types;
2 | using HA.Domain.Entities;
3 |
4 | namespace HA.GraphQL.Types
5 | {
6 | public class DealGraphType : ObjectGraphType
7 | {
8 | public DealGraphType()
9 | {
10 | Name = "Deal";
11 | Field(x => x.Id, type: typeof(IdGraphType)).Description("Deal Id");
12 | Field(x => x.Name).Description("Deal Name");
13 | Field(x => x.Description).Description("Deal descriptions");
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/HA.GraphQL/HA.GraphQL.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp3.1
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/HA.GraphQL/Program.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Hosting;
2 | using Microsoft.Extensions.Hosting;
3 |
4 | namespace HA.GraphQL
5 | {
6 | public class Program
7 | {
8 | public static void Main(string[] args)
9 | {
10 | CreateHostBuilder(args).Build().Run();
11 | }
12 |
13 | public static IHostBuilder CreateHostBuilder(string[] args) =>
14 | Host.CreateDefaultBuilder(args)
15 | .ConfigureWebHostDefaults(webBuilder =>
16 | {
17 | webBuilder.UseStartup();
18 | });
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/HA.GraphQL/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "iisSettings": {
3 | "windowsAuthentication": false,
4 | "anonymousAuthentication": true,
5 | "iisExpress": {
6 | "applicationUrl": "http://localhost:54736",
7 | "sslPort": 0
8 | }
9 | },
10 | "profiles": {
11 | "IIS Express": {
12 | "commandName": "IISExpress",
13 | "launchBrowser": true,
14 | "launchUrl": "ui/playground",
15 | "environmentVariables": {
16 | "ASPNETCORE_ENVIRONMENT": "Development"
17 | }
18 | },
19 | "HA.GraphQL": {
20 | "commandName": "Project",
21 | "dotnetRunMessages": "true",
22 | "launchBrowser": true,
23 | "launchUrl": "ui/playground",
24 | "applicationUrl": "http://localhost:5000",
25 | "environmentVariables": {
26 | "ASPNETCORE_ENVIRONMENT": "Development"
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/HA.GraphQL/Query-schema.txt:
--------------------------------------------------------------------------------
1 | {
2 | deal(id:"a1bb0bb1-bd10-4de9-b03b-60486102f85b"){
3 | id
4 | name
5 | description
6 | }
7 | }
8 | ------------------
9 | {
10 | deals{
11 | id
12 | name
13 | description
14 | }
15 | }
16 | ------------------
17 | # Remane or alias
18 | {
19 | results: deals{
20 | id
21 | dealname : name
22 | description
23 | }
24 | }
25 | ------------------
26 | # Two queries
27 | {
28 | id1:deal(id:"75f1b113-b17a-4203-ba52-44f77fe67977"){id name description}
29 | id2:deal(id:"a1bb0bb1-bd10-4de9-b03b-60486102f85b"){id name description}
30 | }
31 | ------------------
32 | # Fragment
33 | {
34 | id1:deal(id:"75f1b113-b17a-4203-ba52-44f77fe67977"){...comparisonFields}
35 | id2:deal(id:"a1bb0bb1-bd10-4de9-b03b-60486102f85b"){...comparisonFields}
36 | }
37 |
38 | fragment comparisonFields on Deal{
39 | id, name, description
40 | }
41 |
--------------------------------------------------------------------------------
/src/HA.GraphQL/Startup.cs:
--------------------------------------------------------------------------------
1 | using GraphQL;
2 | using GraphQL.Server;
3 | using GraphQL.Server.Ui.Playground;
4 | using HA.Adapter.Persistence;
5 | using HA.Domain.Services;
6 | using Microsoft.AspNetCore.Builder;
7 | using Microsoft.AspNetCore.Hosting;
8 | using Microsoft.AspNetCore.Server.Kestrel.Core;
9 | using Microsoft.Extensions.Configuration;
10 | using Microsoft.Extensions.DependencyInjection;
11 | using Microsoft.Extensions.Hosting;
12 |
13 | namespace HA.GraphQL
14 | {
15 | public class Startup
16 | {
17 | private IConfiguration Configuration { get; }
18 | private AppSettings AppSettings { get; set; }
19 | public Startup(IConfiguration configuration)
20 | {
21 | Configuration = configuration;
22 |
23 | AppSettings = new AppSettings();
24 | Configuration.Bind(AppSettings);
25 | }
26 |
27 | public void ConfigureServices(IServiceCollection services)
28 | {
29 | services.AddPersistence(Configuration, AppSettings);
30 |
31 | services.AddScoped(s => new FuncDependencyResolver(s.GetRequiredService));
32 | services.AddScoped();
33 |
34 | services.AddGraphQL(o => o.ExposeExceptions = true)
35 | .AddGraphTypes(ServiceLifetime.Scoped)
36 | .AddDataLoader();
37 | services.Configure(options => options.AllowSynchronousIO = true);
38 | services.Configure(options => options.AllowSynchronousIO = true);
39 |
40 | }
41 |
42 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
43 | {
44 | if (env.IsDevelopment())
45 | {
46 | app.UseDeveloperExceptionPage();
47 | }
48 |
49 | app.UseHttpsRedirection();
50 |
51 | app.UseRouting();
52 |
53 | app.UseGraphQL();
54 | app.UseGraphQLPlayground(options: new GraphQLPlaygroundOptions());
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/src/HA.GraphQL/appsettings.Development.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft": "Warning",
6 | "Microsoft.Hosting.Lifetime": "Information"
7 | }
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/src/HA.GraphQL/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "ConnectionStrings": {
3 | "HexaArchConn": "Data Source=(local)\\SQLexpress01;Initial Catalog=HexaDb;Integrated Security=True"
4 | },
5 | "Logging": {
6 | "LogLevel": {
7 | "Default": "Information",
8 | "Microsoft": "Warning",
9 | "Microsoft.Hosting.Lifetime": "Information"
10 | }
11 | },
12 | "AllowedHosts": "*"
13 | }
14 |
--------------------------------------------------------------------------------
/src/HA.WebAPI.Integration.Test/DealApiTest.cs:
--------------------------------------------------------------------------------
1 | using NUnit.Framework;
2 | using System.Net;
3 | using System.Net.Http;
4 | using System.Threading.Tasks;
5 |
6 | namespace HA.WebAPI.Integration.Test
7 | {
8 | public class DealApiTest
9 | {
10 | [TestCase("Get", "api/v1/deal")]
11 | [TestCase("Get", "api/v1/deal/guid")]
12 | [Ignore("Need to implement")]
13 | public async Task GetAllCustomerTestAsync(string method, string URL)
14 | {
15 | using var client = new TestClientProvider().Client;
16 | var request = new HttpRequestMessage(new HttpMethod(method), URL);
17 | var response = await client.SendAsync(request);
18 |
19 | response.EnsureSuccessStatusCode();
20 | Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
21 | }
22 | }
23 | }
--------------------------------------------------------------------------------
/src/HA.WebAPI.Integration.Test/HA.WebAPI.Integration.Test.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp3.1
5 |
6 | false
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/src/HA.WebAPI.Integration.Test/TestClientProvider.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Hosting;
2 | using Microsoft.AspNetCore.TestHost;
3 | using System.Net.Http;
4 |
5 | namespace HA.WebAPI.Integration.Test
6 | {
7 | public class TestClientProvider
8 | {
9 | public HttpClient Client { get; private set; }
10 | public TestClientProvider()
11 | {
12 | var server = new TestServer(new WebHostBuilder().UseStartup());
13 | Client = server.CreateClient();
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/HA.WebAPI/Controllers/MetaController.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Mvc;
2 | using System.Diagnostics;
3 |
4 | namespace HA.WebAPI.Controllers
5 | {
6 | public class MetaController : ControllerBase
7 | {
8 | [HttpGet("/info")]
9 | public ActionResult Info()
10 | {
11 | var assembly = typeof(Startup).Assembly;
12 |
13 | var lastUpdate = System.IO.File.GetLastWriteTime(assembly.Location);
14 | var version = FileVersionInfo.GetVersionInfo(assembly.Location).ProductVersion;
15 |
16 | return Ok($"Version: {version}, Last Updated: {lastUpdate}");
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/HA.WebAPI/HA.WebAPI.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp3.1
5 |
6 |
7 |
8 | HA.WebAPI.xml
9 | 1701;1702;1591
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/src/HA.WebAPI/HA.WebAPI.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | HA.WebAPI
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/src/HA.WebAPI/Program.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Hosting;
2 | using Microsoft.Extensions.Hosting;
3 |
4 | namespace HA.WebAPI
5 | {
6 | public class Program
7 | {
8 | public static void Main(string[] args)
9 | {
10 | CreateHostBuilder(args).Build().Run();
11 | }
12 |
13 | public static IHostBuilder CreateHostBuilder(string[] args) =>
14 | Host.CreateDefaultBuilder(args)
15 | .ConfigureWebHostDefaults(webBuilder =>
16 | {
17 | webBuilder.UseStartup();
18 | });
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/HA.WebAPI/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json.schemastore.org/launchsettings.json",
3 | "iisSettings": {
4 | "windowsAuthentication": false,
5 | "anonymousAuthentication": true,
6 | "iisExpress": {
7 | "applicationUrl": "http://localhost:50065",
8 | "sslPort": 44333
9 | }
10 | },
11 | "profiles": {
12 | "IIS Express": {
13 | "commandName": "IISExpress",
14 | "launchBrowser": true,
15 | "launchUrl": "OpenAPI/index.html",
16 | "environmentVariables": {
17 | "ASPNETCORE_ENVIRONMENT": "Development"
18 | }
19 | },
20 | "HA.WebAPI": {
21 | "commandName": "Project",
22 | "launchBrowser": true,
23 | "launchUrl": "OpenAPI/index.html",
24 | "applicationUrl": "https://localhost:5001;http://localhost:5000",
25 | "environmentVariables": {
26 | "ASPNETCORE_ENVIRONMENT": "Development"
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/HA.WebAPI/Startup.cs:
--------------------------------------------------------------------------------
1 | using HA.Adapter.DealModule;
2 | using HA.Adapter.Persistence;
3 | using HA.Application;
4 | using HA.Domain.Services;
5 | using HealthChecks.UI.Client;
6 | using Microsoft.AspNetCore.Builder;
7 | using Microsoft.AspNetCore.Diagnostics.HealthChecks;
8 | using Microsoft.AspNetCore.Hosting;
9 | using Microsoft.AspNetCore.Http;
10 | using Microsoft.Extensions.Configuration;
11 | using Microsoft.Extensions.DependencyInjection;
12 | using Microsoft.Extensions.Diagnostics.HealthChecks;
13 | using Microsoft.Extensions.Hosting;
14 | using Microsoft.Extensions.Logging;
15 | using Serilog;
16 | using System;
17 | using System.IO;
18 | using System.Reflection;
19 |
20 | namespace HA.WebAPI
21 | {
22 | public class Startup
23 | {
24 | private IConfiguration Configuration { get; }
25 | private AppSettings AppSettings { get; set; }
26 | public Startup(IConfiguration configuration)
27 | {
28 | Log.Logger = new LoggerConfiguration().ReadFrom.Configuration(configuration).CreateLogger();
29 | Configuration = configuration;
30 |
31 | AppSettings = new AppSettings();
32 | Configuration.Bind(AppSettings);
33 | }
34 |
35 | public void ConfigureServices(IServiceCollection services)
36 | {
37 | services.AddControllers();
38 |
39 | services.AddApplication();
40 |
41 | services.AddDealModule();
42 |
43 | services.AddPersistence(Configuration, AppSettings);
44 |
45 | services.AddMemoryCache();
46 |
47 | services.AddMiniProfiler(options => options.RouteBasePath = "/profiler").AddEntityFramework();
48 |
49 | // Todo: move to infrastucture layer
50 | services.AddSwaggerGen(setupAction =>
51 | {
52 | setupAction.SwaggerDoc(
53 | "OpenAPISpecification",
54 | new Microsoft.OpenApi.Models.OpenApiInfo()
55 | {
56 | Title = "Hexagonal Architecture WebAPI",
57 | Version = "1",
58 | Description = "Through this API you can access details",
59 | Contact = new Microsoft.OpenApi.Models.OpenApiContact()
60 | {
61 | Email = "amit.naik8103@gmail.com",
62 | Name = "Amit Naik",
63 | Url = new Uri(AppSettings.ApplicationDetail.ContactWebsite)
64 | },
65 | License = new Microsoft.OpenApi.Models.OpenApiLicense()
66 | {
67 | Name = "MIT License",
68 | Url = new Uri(AppSettings.ApplicationDetail.LicenseDetail)
69 | }
70 | });
71 | var xmlCommentsFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
72 | var xmlCommentsFullPath = Path.Combine(AppContext.BaseDirectory, xmlCommentsFile);
73 | setupAction.IncludeXmlComments(xmlCommentsFullPath);
74 | });
75 |
76 | services.AddHealthChecks()
77 | .AddUrlGroup(new Uri(AppSettings.ApplicationDetail.ContactWebsite), name: "My personal website", failureStatus: HealthStatus.Degraded)
78 | .AddSqlServer(Configuration.GetConnectionString("HexaArchConn"));
79 |
80 | services.AddHealthChecksUI(setupSettings: setup =>
81 | {
82 | setup.AddHealthCheckEndpoint("Basic Health Check", $"/healthz");
83 | });
84 | }
85 |
86 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory log)
87 | {
88 | if (env.IsDevelopment())
89 | {
90 | app.UseDeveloperExceptionPage();
91 | }
92 |
93 | log.AddSerilog();
94 |
95 | app.UseExceptionHandlerMiddleware();
96 |
97 | app.UseSwagger();
98 |
99 | app.UseSwaggerUI(setupAction =>
100 | {
101 | setupAction.SwaggerEndpoint("/swagger/OpenAPISpecification/swagger.json", "Hexagonal Architecture WebAPI");
102 | setupAction.RoutePrefix = "OpenAPI";
103 | });
104 |
105 | app.UseMiniProfiler();
106 |
107 | app.UseHealthChecks("/healthz", new HealthCheckOptions
108 | {
109 | Predicate = _ => true,
110 | ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse,
111 | ResultStatusCodes =
112 | {
113 | [HealthStatus.Healthy] = StatusCodes.Status200OK,
114 | [HealthStatus.Degraded] = StatusCodes.Status500InternalServerError,
115 | [HealthStatus.Unhealthy] = StatusCodes.Status503ServiceUnavailable,
116 | },
117 | }).UseHealthChecksUI(setup =>
118 | {
119 | setup.ApiPath = "/healthcheck";
120 | setup.UIPath = "/healthcheck-ui";
121 | });
122 |
123 | app.UseHttpsRedirection();
124 |
125 | app.UseRouting();
126 |
127 | app.UseAuthorization();
128 |
129 | app.UseEndpoints(endpoints =>
130 | {
131 | endpoints.MapControllers();
132 | });
133 | }
134 | }
135 | }
136 |
--------------------------------------------------------------------------------
/src/HA.WebAPI/appsettings.Development.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft": "Warning",
6 | "Microsoft.Hosting.Lifetime": "Information"
7 | }
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/src/HA.WebAPI/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "UseInMemoryDatabase": false,
3 | "ConnectionStrings": {
4 | "HexaArchConn": "Data Source=(local)\\SQLexpress01;Initial Catalog=HexaDb;Integrated Security=True"
5 | },
6 | "ApplicationDetail": {
7 | "ContactWebsite": "https://amitpnk.github.io/",
8 | "LicenseDetail": "https://opensource.org/licenses/MIT"
9 | },
10 | "Serilog": {
11 | "MinimumLevel": "Information",
12 | "WriteTo": [
13 | {
14 | "Name": "RollingFile",
15 | "Args": {
16 | "pathFormat": "D:\\Logs\\HA-log-{Date}.log",
17 | "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] {Message}{NewLine}{Exception}"
18 | }
19 | },
20 | {
21 | "Name": "MSSqlServer",
22 | "Args": {
23 | "connectionString": "Data Source=(local)\\SQLexpress01;Initial Catalog=HexaDb;Integrated Security=True",
24 | "sinkOptionsSection": {
25 | "tableName": "Logs",
26 | "schemaName": "EventLogging",
27 | "autoCreateSqlTable": true
28 | },
29 | "restrictedToMinimumLevel": "Warning"
30 | }
31 | }
32 | ],
33 | "Properties": {
34 | "Application": "Hexagonal Architecture application"
35 | }
36 | },
37 | "AllowedHosts": "*"
38 | }
39 |
--------------------------------------------------------------------------------
/url.txt:
--------------------------------------------------------------------------------
1 | /profiler/results-index
2 | /profiler/results
3 | /profiler/results-list
--------------------------------------------------------------------------------