├── .dockerignore ├── .gitattributes ├── .gitignore ├── LICENSE ├── README.md ├── TodoList.sln ├── db-init └── init.sql ├── docker-compose.dcproj ├── docker-compose.override.yml ├── docker-compose.yml ├── launchSettings.json ├── src ├── TodoList.API │ ├── Controllers │ │ └── TodosController.cs │ ├── Dockerfile │ ├── Program.cs │ ├── Properties │ │ └── launchSettings.json │ ├── TodoList.API.csproj │ ├── appsettings.Development.json │ └── appsettings.json ├── TodoList.Application │ ├── Context │ │ └── DapperUnitOfWork.cs │ ├── DependencyInjection.cs │ ├── TodoItems │ │ ├── CreateTodoItem │ │ │ ├── CreateTodoItemCommand.cs │ │ │ └── CreateTodoItemCommandHandler.cs │ │ ├── DeleteTodoItem │ │ │ ├── DeleteTodoItemCommand.cs │ │ │ └── DeleteTodoItemCommandHandler.cs │ │ ├── GetAllTodoItems │ │ │ ├── GetAllTodoItemsQuery.cs │ │ │ └── GetAllTodoItemsQueryHandler.cs │ │ ├── GetTodoItem │ │ │ ├── GetTodoItemByIdQuery.cs │ │ │ └── GetTodoItemByIdQueryHandler.cs │ │ ├── TodoItemResponse.cs │ │ └── UpdateTodoItem │ │ │ ├── UpdateTodoItemCommand.cs │ │ │ └── UpdateTodoItemCommandHandler.cs │ └── TodoList.Application.csproj ├── TodoList.Domain │ ├── Abstractions │ │ ├── BaseEntity.cs │ │ ├── IDomainEvent.cs │ │ └── IUnitOfWork.cs │ ├── TodoItems │ │ ├── Events │ │ │ └── TodoItemCompletedEvent.cs │ │ ├── ITodoItemRepository.cs │ │ ├── PrioritySuggestionService.cs │ │ └── TodoItem.cs │ └── TodoList.Domain.csproj └── TodoList.Infrastructure │ ├── Data │ ├── DateOnlyHandler.cs │ └── MySqlConnectionFactory.cs │ ├── DependencyInjection.cs │ ├── Repositories │ └── TodoItemRepository.cs │ └── TodoList.Infrastructure.csproj └── test ├── TodoList.Application.UnitTests ├── GlobalUsings.cs ├── TodoItems │ ├── Commands │ │ └── CreateTodoItemCommandHandlerTests.cs │ └── Queries │ │ └── GetTodoItemByIdQueryHandlerTests.cs └── TodoList.Application.UnitTests.csproj ├── TodoList.ArchitectureTests ├── BaseTest.cs ├── GlobalUsings.cs ├── LayerTests.cs └── TodoList.ArchitectureTests.csproj └── TodoList.Domain.UnitTests ├── GlobalUsings.cs ├── TodoItems ├── PrioritySuggestionServiceTests.cs └── TodoItemTests.cs └── TodoList.Domain.UnitTests.csproj /.dockerignore: -------------------------------------------------------------------------------- 1 | **/.classpath 2 | **/.dockerignore 3 | **/.env 4 | **/.git 5 | **/.gitignore 6 | **/.project 7 | **/.settings 8 | **/.toolstarget 9 | **/.vs 10 | **/.vscode 11 | **/*.*proj.user 12 | **/*.dbmdl 13 | **/*.jfm 14 | **/azds.yaml 15 | **/bin 16 | **/charts 17 | **/docker-compose* 18 | **/Dockerfile* 19 | **/node_modules 20 | **/npm-debug.log 21 | **/obj 22 | **/secrets.dev.yaml 23 | **/values.dev.yaml 24 | LICENSE 25 | README.md -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.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 | [Ww][Ii][Nn]32/ 27 | [Aa][Rr][Mm]/ 28 | [Aa][Rr][Mm]64/ 29 | bld/ 30 | [Bb]in/ 31 | [Oo]bj/ 32 | [Oo]ut/ 33 | [Ll]og/ 34 | [Ll]ogs/ 35 | 36 | # Visual Studio 2015/2017 cache/options directory 37 | .vs/ 38 | # Uncomment if you have tasks that create the project's static files in wwwroot 39 | #wwwroot/ 40 | 41 | # Visual Studio 2017 auto generated files 42 | Generated\ Files/ 43 | 44 | # MSTest test Results 45 | [Tt]est[Rr]esult*/ 46 | [Bb]uild[Ll]og.* 47 | 48 | # NUnit 49 | *.VisualState.xml 50 | TestResult.xml 51 | nunit-*.xml 52 | 53 | # Build Results of an ATL Project 54 | [Dd]ebugPS/ 55 | [Rr]eleasePS/ 56 | dlldata.c 57 | 58 | # Benchmark Results 59 | BenchmarkDotNet.Artifacts/ 60 | 61 | # .NET Core 62 | project.lock.json 63 | project.fragment.lock.json 64 | artifacts/ 65 | 66 | # ASP.NET Scaffolding 67 | ScaffoldingReadMe.txt 68 | 69 | # StyleCop 70 | StyleCopReport.xml 71 | 72 | # Files built by Visual Studio 73 | *_i.c 74 | *_p.c 75 | *_h.h 76 | *.ilk 77 | *.meta 78 | *.obj 79 | *.iobj 80 | *.pch 81 | *.pdb 82 | *.ipdb 83 | *.pgc 84 | *.pgd 85 | *.rsp 86 | *.sbr 87 | *.tlb 88 | *.tli 89 | *.tlh 90 | *.tmp 91 | *.tmp_proj 92 | *_wpftmp.csproj 93 | *.log 94 | *.vspscc 95 | *.vssscc 96 | .builds 97 | *.pidb 98 | *.svclog 99 | *.scc 100 | 101 | # Chutzpah Test files 102 | _Chutzpah* 103 | 104 | # Visual C++ cache files 105 | ipch/ 106 | *.aps 107 | *.ncb 108 | *.opendb 109 | *.opensdf 110 | *.sdf 111 | *.cachefile 112 | *.VC.db 113 | *.VC.VC.opendb 114 | 115 | # Visual Studio profiler 116 | *.psess 117 | *.vsp 118 | *.vspx 119 | *.sap 120 | 121 | # Visual Studio Trace Files 122 | *.e2e 123 | 124 | # TFS 2012 Local Workspace 125 | $tf/ 126 | 127 | # Guidance Automation Toolkit 128 | *.gpState 129 | 130 | # ReSharper is a .NET coding add-in 131 | _ReSharper*/ 132 | *.[Rr]e[Ss]harper 133 | *.DotSettings.user 134 | 135 | # TeamCity is a build add-in 136 | _TeamCity* 137 | 138 | # DotCover is a Code Coverage Tool 139 | *.dotCover 140 | 141 | # AxoCover is a Code Coverage Tool 142 | .axoCover/* 143 | !.axoCover/settings.json 144 | 145 | # Coverlet is a free, cross platform Code Coverage Tool 146 | coverage*.json 147 | coverage*.xml 148 | coverage*.info 149 | 150 | # Visual Studio code coverage results 151 | *.coverage 152 | *.coveragexml 153 | 154 | # NCrunch 155 | _NCrunch_* 156 | .*crunch*.local.xml 157 | nCrunchTemp_* 158 | 159 | # MightyMoose 160 | *.mm.* 161 | AutoTest.Net/ 162 | 163 | # Web workbench (sass) 164 | .sass-cache/ 165 | 166 | # Installshield output folder 167 | [Ee]xpress/ 168 | 169 | # DocProject is a documentation generator add-in 170 | DocProject/buildhelp/ 171 | DocProject/Help/*.HxT 172 | DocProject/Help/*.HxC 173 | DocProject/Help/*.hhc 174 | DocProject/Help/*.hhk 175 | DocProject/Help/*.hhp 176 | DocProject/Help/Html2 177 | DocProject/Help/html 178 | 179 | # Click-Once directory 180 | publish/ 181 | 182 | # Publish Web Output 183 | *.[Pp]ublish.xml 184 | *.azurePubxml 185 | # Note: Comment the next line if you want to checkin your web deploy settings, 186 | # but database connection strings (with potential passwords) will be unencrypted 187 | *.pubxml 188 | *.publishproj 189 | 190 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 191 | # checkin your Azure Web App publish settings, but sensitive information contained 192 | # in these scripts will be unencrypted 193 | PublishScripts/ 194 | 195 | # NuGet Packages 196 | *.nupkg 197 | # NuGet Symbol Packages 198 | *.snupkg 199 | # The packages folder can be ignored because of Package Restore 200 | **/[Pp]ackages/* 201 | # except build/, which is used as an MSBuild target. 202 | !**/[Pp]ackages/build/ 203 | # Uncomment if necessary however generally it will be regenerated when needed 204 | #!**/[Pp]ackages/repositories.config 205 | # NuGet v3's project.json files produces more ignorable files 206 | *.nuget.props 207 | *.nuget.targets 208 | 209 | # Microsoft Azure Build Output 210 | csx/ 211 | *.build.csdef 212 | 213 | # Microsoft Azure Emulator 214 | ecf/ 215 | rcf/ 216 | 217 | # Windows Store app package directories and files 218 | AppPackages/ 219 | BundleArtifacts/ 220 | Package.StoreAssociation.xml 221 | _pkginfo.txt 222 | *.appx 223 | *.appxbundle 224 | *.appxupload 225 | 226 | # Visual Studio cache files 227 | # files ending in .cache can be ignored 228 | *.[Cc]ache 229 | # but keep track of directories ending in .cache 230 | !?*.[Cc]ache/ 231 | 232 | # Others 233 | ClientBin/ 234 | ~$* 235 | *~ 236 | *.dbmdl 237 | *.dbproj.schemaview 238 | *.jfm 239 | *.pfx 240 | *.publishsettings 241 | orleans.codegen.cs 242 | 243 | # Including strong name files can present a security risk 244 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 245 | #*.snk 246 | 247 | # Since there are multiple workflows, uncomment next line to ignore bower_components 248 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 249 | #bower_components/ 250 | 251 | # RIA/Silverlight projects 252 | Generated_Code/ 253 | 254 | # Backup & report files from converting an old project file 255 | # to a newer Visual Studio version. Backup files are not needed, 256 | # because we have git ;-) 257 | _UpgradeReport_Files/ 258 | Backup*/ 259 | UpgradeLog*.XML 260 | UpgradeLog*.htm 261 | ServiceFabricBackup/ 262 | *.rptproj.bak 263 | 264 | # SQL Server files 265 | *.mdf 266 | *.ldf 267 | *.ndf 268 | 269 | # Business Intelligence projects 270 | *.rdl.data 271 | *.bim.layout 272 | *.bim_*.settings 273 | *.rptproj.rsuser 274 | *- [Bb]ackup.rdl 275 | *- [Bb]ackup ([0-9]).rdl 276 | *- [Bb]ackup ([0-9][0-9]).rdl 277 | 278 | # Microsoft Fakes 279 | FakesAssemblies/ 280 | 281 | # GhostDoc plugin setting file 282 | *.GhostDoc.xml 283 | 284 | # Node.js Tools for Visual Studio 285 | .ntvs_analysis.dat 286 | node_modules/ 287 | 288 | # Visual Studio 6 build log 289 | *.plg 290 | 291 | # Visual Studio 6 workspace options file 292 | *.opt 293 | 294 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 295 | *.vbw 296 | 297 | # Visual Studio LightSwitch build output 298 | **/*.HTMLClient/GeneratedArtifacts 299 | **/*.DesktopClient/GeneratedArtifacts 300 | **/*.DesktopClient/ModelManifest.xml 301 | **/*.Server/GeneratedArtifacts 302 | **/*.Server/ModelManifest.xml 303 | _Pvt_Extensions 304 | 305 | # Paket dependency manager 306 | .paket/paket.exe 307 | paket-files/ 308 | 309 | # FAKE - F# Make 310 | .fake/ 311 | 312 | # CodeRush personal settings 313 | .cr/personal 314 | 315 | # Python Tools for Visual Studio (PTVS) 316 | __pycache__/ 317 | *.pyc 318 | 319 | # Cake - Uncomment if you are using it 320 | # tools/** 321 | # !tools/packages.config 322 | 323 | # Tabs Studio 324 | *.tss 325 | 326 | # Telerik's JustMock configuration file 327 | *.jmconfig 328 | 329 | # BizTalk build output 330 | *.btp.cs 331 | *.btm.cs 332 | *.odx.cs 333 | *.xsd.cs 334 | 335 | # OpenCover UI analysis results 336 | OpenCover/ 337 | 338 | # Azure Stream Analytics local run output 339 | ASALocalRun/ 340 | 341 | # MSBuild Binary and Structured Log 342 | *.binlog 343 | 344 | # NVidia Nsight GPU debugger configuration file 345 | *.nvuser 346 | 347 | # MFractors (Xamarin productivity tool) working folder 348 | .mfractor/ 349 | 350 | # Local History for Visual Studio 351 | .localhistory/ 352 | 353 | # BeatPulse healthcheck temp database 354 | healthchecksdb 355 | 356 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 357 | MigrationBackup/ 358 | 359 | # Ionide (cross platform F# VS Code tools) working folder 360 | .ionide/ 361 | 362 | # Fody - auto-generated XML schema 363 | FodyWeavers.xsd -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Joshua Torres 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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Clean Architecture with ASP.NET Core, Dapper, and MySQL 2 | A simple Todo App API used as an example of a Clean Architecture approach in an ASP.NET Core, leveraging Dapper as the ORM and MySQL as the database. 3 | 4 | ## 🚀 Features 5 | * **Clean Architecture**: Clear separation of concerns with four main layers: API, Application, Domain, and Infrastructure. 6 | * **Dapper ORM**: Flexible and fast micro ORM. 7 | * **MySQL**: Robust open-source relational database. 8 | * **CQRS with MediatR**: Command Query Responsibility Segregation to clearly differentiate read and write actions. 9 | * **Docker-Compose**: Easily containerize the application for consistent development and deployment experiences. 10 | 11 | ## 📚 Project Structure 12 | * **API Layer**: Entry point of the application. Contains the ASP.NET Core Web API setup, controllers, and DI configuration. 13 | * **Application Layer**: Houses the application's business logic, DTOs, interfaces, and application-specific services. Contains MediatR commands and queries. 14 | * **Domain Layer**: Core layer of the project. Contains all the domain entities, value objects, domain events, and domain services. 15 | * **Infrastructure Layer**: Deals with the external concerns, data access, and other integrations. Contains the Dapper ORM configurations and repository implementations. 16 | 17 | ## 🐋 Docker-Compose 18 | This project includes a `docker-compose.yml file` to help you containerize your application. This simplifies setup, especially for contributors who want to run the project without manually configuring external dependencies like MySQL. 19 | 20 | ### Running with Docker 21 | Ensure you have Docker and Docker-Compose installed. Then: 22 | 23 | ``` 24 | docker-compose up --build 25 | ``` 26 | 27 | This will build the required images and start the containers. Once running, you can access the API typically at `http://localhost:`. 28 | 29 | ## 🌱 Getting Started 30 | 1. Clone this repository: 31 | ``` 32 | git clone https://github.com/nekomatadev/clean-architecture-demo.git 33 | ``` 34 | 2. Navigate to the project directory: 35 | ``` 36 | cd path-to-project-directory 37 | ``` 38 | 3. Use Docker-Compose to run the application: 39 | ``` 40 | docker-compose up --build 41 | ``` 42 | 43 | ## 📜 License 44 | [MIT](https://choosealicense.com/licenses/mit/) 45 | 46 | -------------------------------------------------------------------------------- /TodoList.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.7.34024.191 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{716BD6D4-3D8E-4B5F-88C7-5B6DA7B20207}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TodoList.Domain", "src\TodoList.Domain\TodoList.Domain.csproj", "{1B853FAC-EFD1-40A5-9ED3-BB90A6C8AF53}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TodoList.Application", "src\TodoList.Application\TodoList.Application.csproj", "{599A36D3-D35F-4BE3-8CED-5146140FE511}" 11 | EndProject 12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TodoList.Infrastructure", "src\TodoList.Infrastructure\TodoList.Infrastructure.csproj", "{E9D65161-5131-4970-A8EB-77181B7D99E1}" 13 | EndProject 14 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TodoList.API", "src\TodoList.API\TodoList.API.csproj", "{B9EF36A1-95CE-4A57-9392-B0686FFDEBC7}" 15 | EndProject 16 | Project("{E53339B2-1760-4266-BCC7-CA923CBCF16C}") = "docker-compose", "docker-compose.dcproj", "{C727AAC6-FCE7-4C5A-83EF-56B4E0D08B94}" 17 | EndProject 18 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{416DECE0-0B48-4057-99CD-3CE2664EF29F}" 19 | EndProject 20 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TodoList.ArchitectureTests", "test\TodoList.ArchitectureTests\TodoList.ArchitectureTests.csproj", "{8F5A8CBF-9E88-456C-9F31-E9448465DB42}" 21 | EndProject 22 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TodoList.Domain.UnitTests", "test\TodoList.Domain.UnitTests\TodoList.Domain.UnitTests.csproj", "{55E73402-A94C-448F-9345-A42E7848A82C}" 23 | EndProject 24 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TodoList.Application.UnitTests", "test\TodoList.Application.UnitTests\TodoList.Application.UnitTests.csproj", "{D5DC5B40-E53C-4F82-B8BA-8D0C1DD60AE7}" 25 | EndProject 26 | Global 27 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 28 | Debug|Any CPU = Debug|Any CPU 29 | Release|Any CPU = Release|Any CPU 30 | EndGlobalSection 31 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 32 | {1B853FAC-EFD1-40A5-9ED3-BB90A6C8AF53}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 33 | {1B853FAC-EFD1-40A5-9ED3-BB90A6C8AF53}.Debug|Any CPU.Build.0 = Debug|Any CPU 34 | {1B853FAC-EFD1-40A5-9ED3-BB90A6C8AF53}.Release|Any CPU.ActiveCfg = Release|Any CPU 35 | {1B853FAC-EFD1-40A5-9ED3-BB90A6C8AF53}.Release|Any CPU.Build.0 = Release|Any CPU 36 | {599A36D3-D35F-4BE3-8CED-5146140FE511}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 37 | {599A36D3-D35F-4BE3-8CED-5146140FE511}.Debug|Any CPU.Build.0 = Debug|Any CPU 38 | {599A36D3-D35F-4BE3-8CED-5146140FE511}.Release|Any CPU.ActiveCfg = Release|Any CPU 39 | {599A36D3-D35F-4BE3-8CED-5146140FE511}.Release|Any CPU.Build.0 = Release|Any CPU 40 | {E9D65161-5131-4970-A8EB-77181B7D99E1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 41 | {E9D65161-5131-4970-A8EB-77181B7D99E1}.Debug|Any CPU.Build.0 = Debug|Any CPU 42 | {E9D65161-5131-4970-A8EB-77181B7D99E1}.Release|Any CPU.ActiveCfg = Release|Any CPU 43 | {E9D65161-5131-4970-A8EB-77181B7D99E1}.Release|Any CPU.Build.0 = Release|Any CPU 44 | {B9EF36A1-95CE-4A57-9392-B0686FFDEBC7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 45 | {B9EF36A1-95CE-4A57-9392-B0686FFDEBC7}.Debug|Any CPU.Build.0 = Debug|Any CPU 46 | {B9EF36A1-95CE-4A57-9392-B0686FFDEBC7}.Release|Any CPU.ActiveCfg = Release|Any CPU 47 | {B9EF36A1-95CE-4A57-9392-B0686FFDEBC7}.Release|Any CPU.Build.0 = Release|Any CPU 48 | {C727AAC6-FCE7-4C5A-83EF-56B4E0D08B94}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 49 | {C727AAC6-FCE7-4C5A-83EF-56B4E0D08B94}.Debug|Any CPU.Build.0 = Debug|Any CPU 50 | {C727AAC6-FCE7-4C5A-83EF-56B4E0D08B94}.Release|Any CPU.ActiveCfg = Release|Any CPU 51 | {C727AAC6-FCE7-4C5A-83EF-56B4E0D08B94}.Release|Any CPU.Build.0 = Release|Any CPU 52 | {8F5A8CBF-9E88-456C-9F31-E9448465DB42}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 53 | {8F5A8CBF-9E88-456C-9F31-E9448465DB42}.Debug|Any CPU.Build.0 = Debug|Any CPU 54 | {8F5A8CBF-9E88-456C-9F31-E9448465DB42}.Release|Any CPU.ActiveCfg = Release|Any CPU 55 | {8F5A8CBF-9E88-456C-9F31-E9448465DB42}.Release|Any CPU.Build.0 = Release|Any CPU 56 | {55E73402-A94C-448F-9345-A42E7848A82C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 57 | {55E73402-A94C-448F-9345-A42E7848A82C}.Debug|Any CPU.Build.0 = Debug|Any CPU 58 | {55E73402-A94C-448F-9345-A42E7848A82C}.Release|Any CPU.ActiveCfg = Release|Any CPU 59 | {55E73402-A94C-448F-9345-A42E7848A82C}.Release|Any CPU.Build.0 = Release|Any CPU 60 | {D5DC5B40-E53C-4F82-B8BA-8D0C1DD60AE7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 61 | {D5DC5B40-E53C-4F82-B8BA-8D0C1DD60AE7}.Debug|Any CPU.Build.0 = Debug|Any CPU 62 | {D5DC5B40-E53C-4F82-B8BA-8D0C1DD60AE7}.Release|Any CPU.ActiveCfg = Release|Any CPU 63 | {D5DC5B40-E53C-4F82-B8BA-8D0C1DD60AE7}.Release|Any CPU.Build.0 = Release|Any CPU 64 | EndGlobalSection 65 | GlobalSection(SolutionProperties) = preSolution 66 | HideSolutionNode = FALSE 67 | EndGlobalSection 68 | GlobalSection(NestedProjects) = preSolution 69 | {1B853FAC-EFD1-40A5-9ED3-BB90A6C8AF53} = {716BD6D4-3D8E-4B5F-88C7-5B6DA7B20207} 70 | {599A36D3-D35F-4BE3-8CED-5146140FE511} = {716BD6D4-3D8E-4B5F-88C7-5B6DA7B20207} 71 | {E9D65161-5131-4970-A8EB-77181B7D99E1} = {716BD6D4-3D8E-4B5F-88C7-5B6DA7B20207} 72 | {B9EF36A1-95CE-4A57-9392-B0686FFDEBC7} = {716BD6D4-3D8E-4B5F-88C7-5B6DA7B20207} 73 | {8F5A8CBF-9E88-456C-9F31-E9448465DB42} = {416DECE0-0B48-4057-99CD-3CE2664EF29F} 74 | {55E73402-A94C-448F-9345-A42E7848A82C} = {416DECE0-0B48-4057-99CD-3CE2664EF29F} 75 | {D5DC5B40-E53C-4F82-B8BA-8D0C1DD60AE7} = {416DECE0-0B48-4057-99CD-3CE2664EF29F} 76 | EndGlobalSection 77 | GlobalSection(ExtensibilityGlobals) = postSolution 78 | SolutionGuid = {3CE59B15-9407-470B-99AB-22E773BD87E7} 79 | EndGlobalSection 80 | EndGlobal 81 | -------------------------------------------------------------------------------- /db-init/init.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE IF NOT EXISTS TodoItems ( 2 | Id INT AUTO_INCREMENT PRIMARY KEY, 3 | Title VARCHAR(255) NOT NULL, 4 | DueDate DATE, 5 | IsCompleted BOOLEAN, 6 | Priority VARCHAR(50) 7 | ); 8 | 9 | -- Seed some initial data 10 | INSERT INTO TodoItems (Title, DueDate, IsCompleted, Priority) VALUES 11 | ('Learn Docker', '2023-12-01', false, 'High'), 12 | ('Implement API', '2023-09-20', false, 'Medium'), 13 | ('Read GPT-4 paper', '2023-09-15', false, 'Low'), 14 | ('Set up new server', '2023-09-10', true, 'High'), 15 | ('Design database schema', '2023-09-12', true, 'Medium'), 16 | ('Write unit tests', '2023-09-30', false, 'Medium'), 17 | ('Prepare presentation', '2023-10-10', false, 'High'), 18 | ('Update project documentation', '2023-10-05', true, 'Low'), 19 | ('Attend weekly meeting', '2023-09-14', true, 'Low'), 20 | ('Refactor legacy code', '2023-09-25', false, 'High'), 21 | ('Review pull requests', '2023-09-18', true, 'Medium'), 22 | ('Plan sprint tasks', '2023-10-02', false, 'Medium'), 23 | ('Learn TypeScript', '2023-11-20', false, 'Low'), 24 | ('Backup important files', '2023-10-30', true, 'High'), 25 | ('Configure CI/CD pipeline', '2023-10-15', false, 'Medium'); 26 | -------------------------------------------------------------------------------- /docker-compose.dcproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2.1 5 | Linux 6 | c727aac6-fce7-4c5a-83ef-56b4e0d08b94 7 | LaunchBrowser 8 | {Scheme}://localhost:{ServicePort}/swagger 9 | todolist.api 10 | 11 | 12 | 13 | docker-compose.yml 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /docker-compose.override.yml: -------------------------------------------------------------------------------- 1 | version: '3.4' 2 | 3 | services: 4 | todolist.api: 5 | environment: 6 | - ASPNETCORE_ENVIRONMENT=Development 7 | - ASPNETCORE_URLS=https://+:443;http://+:80 8 | ports: 9 | - "80" 10 | - "443" 11 | volumes: 12 | - ${APPDATA}/Microsoft/UserSecrets:/root/.microsoft/usersecrets:ro 13 | - ${APPDATA}/ASP.NET/Https:/root/.aspnet/https:ro -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.4' 2 | 3 | services: 4 | todolist.api: 5 | image: ${DOCKER_REGISTRY-}todolistapi 6 | build: 7 | context: . 8 | dockerfile: src/TodoList.API/Dockerfile 9 | ports: 10 | - "5000:80" 11 | depends_on: 12 | - mysql 13 | 14 | mysql: 15 | image: mysql:latest 16 | container_name: mysql 17 | environment: 18 | MYSQL_ROOT_PASSWORD: my-secret-pw 19 | MYSQL_DATABASE: todo_db 20 | ports: 21 | - "3307:3306" 22 | volumes: 23 | - ./db-init:/docker-entrypoint-initdb.d -------------------------------------------------------------------------------- /launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "Docker Compose": { 4 | "commandName": "DockerCompose", 5 | "commandVersion": "1.0", 6 | "serviceActions": { 7 | "todolist.api": "StartDebugging" 8 | } 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /src/TodoList.API/Controllers/TodosController.cs: -------------------------------------------------------------------------------- 1 | using MediatR; 2 | using Microsoft.AspNetCore.Http; 3 | using Microsoft.AspNetCore.Mvc; 4 | using TodoList.Application.TodoItems.CreateTodoItem; 5 | using TodoList.Application.TodoItems.DeleteTodoItem; 6 | using TodoList.Application.TodoItems.GetAllTodoItems; 7 | using TodoList.Application.TodoItems.GetTodoItem; 8 | using TodoList.Application.TodoItems.UpdateTodoItem; 9 | 10 | namespace TodoList.API.Controllers 11 | { 12 | [Route("api/todos")] 13 | [ApiController] 14 | public class TodosController : ControllerBase 15 | { 16 | private readonly IMediator _mediator; 17 | 18 | public TodosController(IMediator mediator) 19 | { 20 | _mediator = mediator; 21 | } 22 | 23 | [HttpPost] 24 | public async Task Create([FromBody] CreateTodoItemCommand command) 25 | { 26 | var result = await _mediator.Send(command); 27 | return CreatedAtAction(nameof(GetById), new { id = result }, command); 28 | } 29 | 30 | [HttpGet] 31 | public async Task GetAll() 32 | { 33 | var result = await _mediator.Send(new GetAllTodoItemsQuery()); 34 | return Ok(result); 35 | } 36 | 37 | [HttpGet("{id}")] 38 | public async Task GetById(int id) 39 | { 40 | var result = await _mediator.Send(new GetTodoItemByIdQuery() { Id = id }); 41 | 42 | if (result == null) 43 | return NotFound(); 44 | 45 | return Ok(result); 46 | } 47 | 48 | [HttpPut("{id}")] 49 | public async Task Update(int id, [FromBody] UpdateTodoItemCommand command) 50 | { 51 | if (id != command.Id) 52 | { 53 | return BadRequest(); 54 | } 55 | 56 | var result = await _mediator.Send(command); 57 | if (result) 58 | return NoContent(); 59 | 60 | return NotFound(); 61 | } 62 | 63 | [HttpDelete("{id}")] 64 | public async Task Delete(int id) 65 | { 66 | var result = await _mediator.Send(new DeleteTodoItemCommand { Id = id }); 67 | if (result) 68 | return NoContent(); 69 | 70 | return NotFound(); 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/TodoList.API/Dockerfile: -------------------------------------------------------------------------------- 1 | #See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging. 2 | 3 | FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base 4 | WORKDIR /app 5 | EXPOSE 80 6 | EXPOSE 443 7 | 8 | FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build 9 | WORKDIR /src 10 | COPY ["src/TodoList.API/TodoList.API.csproj", "src/TodoList.API/"] 11 | RUN dotnet restore "src/TodoList.API/TodoList.API.csproj" 12 | COPY . . 13 | WORKDIR "/src/src/TodoList.API" 14 | RUN dotnet build "TodoList.API.csproj" -c Release -o /app/build 15 | 16 | FROM build AS publish 17 | RUN dotnet publish "TodoList.API.csproj" -c Release -o /app/publish /p:UseAppHost=false 18 | 19 | FROM base AS final 20 | WORKDIR /app 21 | COPY --from=publish /app/publish . 22 | ENTRYPOINT ["dotnet", "TodoList.API.dll"] -------------------------------------------------------------------------------- /src/TodoList.API/Program.cs: -------------------------------------------------------------------------------- 1 | using TodoList.Application; 2 | using TodoList.Infrastructure; 3 | 4 | var builder = WebApplication.CreateBuilder(args); 5 | 6 | builder.Services.AddControllers(); 7 | 8 | builder.Services.AddApplication(); 9 | builder.Services.AddInfrastructure(builder.Configuration); 10 | 11 | builder.Services.AddEndpointsApiExplorer(); 12 | builder.Services.AddSwaggerGen(); 13 | 14 | var app = builder.Build(); 15 | 16 | // Configure the HTTP request pipeline. 17 | if (app.Environment.IsDevelopment()) 18 | { 19 | app.UseSwagger(); 20 | app.UseSwaggerUI(); 21 | } 22 | 23 | app.UseHttpsRedirection(); 24 | 25 | app.UseAuthorization(); 26 | 27 | app.MapControllers(); 28 | 29 | app.Run(); 30 | -------------------------------------------------------------------------------- /src/TodoList.API/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "http": { 4 | "commandName": "Project", 5 | "launchBrowser": true, 6 | "launchUrl": "swagger", 7 | "environmentVariables": { 8 | "ASPNETCORE_ENVIRONMENT": "Development" 9 | }, 10 | "dotnetRunMessages": true, 11 | "applicationUrl": "http://localhost:5087" 12 | }, 13 | "https": { 14 | "commandName": "Project", 15 | "launchBrowser": true, 16 | "launchUrl": "swagger", 17 | "environmentVariables": { 18 | "ASPNETCORE_ENVIRONMENT": "Development" 19 | }, 20 | "dotnetRunMessages": true, 21 | "applicationUrl": "https://localhost:7295;http://localhost:5087" 22 | }, 23 | "IIS Express": { 24 | "commandName": "IISExpress", 25 | "launchBrowser": true, 26 | "launchUrl": "swagger", 27 | "environmentVariables": { 28 | "ASPNETCORE_ENVIRONMENT": "Development" 29 | } 30 | }, 31 | "Docker": { 32 | "commandName": "Docker", 33 | "launchBrowser": true, 34 | "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger", 35 | "environmentVariables": { 36 | "ASPNETCORE_URLS": "https://+:443;http://+:80" 37 | }, 38 | "publishAllPorts": true, 39 | "useSSL": true 40 | } 41 | }, 42 | "$schema": "https://json.schemastore.org/launchsettings.json", 43 | "iisSettings": { 44 | "windowsAuthentication": false, 45 | "anonymousAuthentication": true, 46 | "iisExpress": { 47 | "applicationUrl": "http://localhost:44892", 48 | "sslPort": 44366 49 | } 50 | } 51 | } -------------------------------------------------------------------------------- /src/TodoList.API/TodoList.API.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net7.0 5 | enable 6 | enable 7 | 99437c01-05d4-4f62-aaa4-c74eafdabf3b 8 | Linux 9 | ..\.. 10 | ..\..\docker-compose.dcproj 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/TodoList.API/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "ConnectionStrings": { 3 | "DefaultConnection": "Server=mysql;Database=todo_db;User=root;Password=my-secret-pw;" 4 | }, 5 | "Logging": { 6 | "LogLevel": { 7 | "Default": "Information", 8 | "Microsoft.AspNetCore": "Warning" 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/TodoList.API/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "AllowedHosts": "*" 9 | } 10 | -------------------------------------------------------------------------------- /src/TodoList.Application/Context/DapperUnitOfWork.cs: -------------------------------------------------------------------------------- 1 | // DapperUnitOfWork.cs 2 | 3 | using System.Data; 4 | using MySql.Data.MySqlClient; 5 | using TodoList.Domain.Abstractions; 6 | 7 | namespace TodoList.Application.Context; 8 | 9 | public class DapperUnitOfWork : IUnitOfWork 10 | { 11 | private readonly IDbConnection _connection; 12 | private IDbTransaction _transaction; 13 | 14 | public DapperUnitOfWork(string connectionString) 15 | { 16 | _connection = new MySqlConnection(connectionString); 17 | _connection.Open(); 18 | _transaction = _connection.BeginTransaction(); 19 | } 20 | 21 | public int Commit() 22 | { 23 | try 24 | { 25 | _transaction.Commit(); 26 | return 1; // Successfully committed 27 | } 28 | catch 29 | { 30 | _transaction.Rollback(); 31 | return 0; // Indicates a failure 32 | } 33 | finally 34 | { 35 | _transaction?.Dispose(); 36 | _transaction = _connection.BeginTransaction(); 37 | } 38 | } 39 | 40 | public void Dispose() 41 | { 42 | _transaction?.Commit(); 43 | _connection?.Close(); 44 | } 45 | } -------------------------------------------------------------------------------- /src/TodoList.Application/DependencyInjection.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | using TodoList.Application.Context; 3 | using TodoList.Domain.Abstractions; 4 | using TodoList.Domain.TodoItems; 5 | 6 | namespace TodoList.Application; 7 | 8 | public static class DependencyInjection 9 | { 10 | public static IServiceCollection AddApplication(this IServiceCollection services) 11 | { 12 | // Add MediatR with handlers from the Application assembly 13 | services.AddMediatR(configuration => 14 | { 15 | configuration.RegisterServicesFromAssembly(typeof(DependencyInjection).Assembly); 16 | }); 17 | 18 | // Register UoW, and other services 19 | // services.AddTransient(); 20 | services.AddTransient(); 21 | 22 | return services; 23 | } 24 | } -------------------------------------------------------------------------------- /src/TodoList.Application/TodoItems/CreateTodoItem/CreateTodoItemCommand.cs: -------------------------------------------------------------------------------- 1 | using MediatR; 2 | 3 | namespace TodoList.Application.TodoItems.CreateTodoItem; 4 | 5 | public class CreateTodoItemCommand : IRequest 6 | { 7 | public string Title { get; set; } 8 | public DateOnly DueDate { get; set; } 9 | } 10 | -------------------------------------------------------------------------------- /src/TodoList.Application/TodoItems/CreateTodoItem/CreateTodoItemCommandHandler.cs: -------------------------------------------------------------------------------- 1 | using MediatR; 2 | using TodoList.Domain.Abstractions; 3 | using TodoList.Domain.TodoItems; 4 | 5 | namespace TodoList.Application.TodoItems.CreateTodoItem; 6 | 7 | public class CreateTodoItemCommandHandler : IRequestHandler 8 | { 9 | private readonly ITodoItemRepository _repository; 10 | private readonly IUnitOfWork _unitOfWork; 11 | private readonly PrioritySuggestionService _priorityService; 12 | 13 | public CreateTodoItemCommandHandler(ITodoItemRepository repository, IUnitOfWork unitOfWork, PrioritySuggestionService priorityService) 14 | { 15 | _repository = repository; 16 | _unitOfWork = unitOfWork; 17 | _priorityService = priorityService; 18 | } 19 | 20 | public async Task Handle(CreateTodoItemCommand command, CancellationToken cancellationToken) 21 | { 22 | var todoItem = new TodoItem(command.Title, command.DueDate, _priorityService); 23 | 24 | await _repository.AddAsync(todoItem); 25 | _unitOfWork.Commit(); 26 | 27 | return todoItem.Id; 28 | } 29 | } -------------------------------------------------------------------------------- /src/TodoList.Application/TodoItems/DeleteTodoItem/DeleteTodoItemCommand.cs: -------------------------------------------------------------------------------- 1 | using MediatR; 2 | 3 | namespace TodoList.Application.TodoItems.DeleteTodoItem; 4 | 5 | public class DeleteTodoItemCommand : IRequest 6 | { 7 | public int Id { get; set; } 8 | } -------------------------------------------------------------------------------- /src/TodoList.Application/TodoItems/DeleteTodoItem/DeleteTodoItemCommandHandler.cs: -------------------------------------------------------------------------------- 1 | using MediatR; 2 | using TodoList.Domain.Abstractions; 3 | using TodoList.Domain.TodoItems; 4 | 5 | namespace TodoList.Application.TodoItems.DeleteTodoItem; 6 | 7 | public class DeleteTodoItemCommandHandler : IRequestHandler 8 | { 9 | private readonly ITodoItemRepository _repository; 10 | private readonly IUnitOfWork _unitOfWork; 11 | 12 | public DeleteTodoItemCommandHandler(ITodoItemRepository repository, IUnitOfWork unitOfWork) 13 | { 14 | _repository = repository; 15 | _unitOfWork = unitOfWork; 16 | } 17 | 18 | public async Task Handle(DeleteTodoItemCommand command, CancellationToken cancellationToken) 19 | { 20 | var todoItem = await _repository.GetByIdAsync(command.Id); 21 | if (todoItem == null) return false; 22 | 23 | await _repository.DeleteAsync(command.Id); 24 | _unitOfWork.Commit(); 25 | 26 | return true; 27 | } 28 | } -------------------------------------------------------------------------------- /src/TodoList.Application/TodoItems/GetAllTodoItems/GetAllTodoItemsQuery.cs: -------------------------------------------------------------------------------- 1 | using MediatR; 2 | 3 | namespace TodoList.Application.TodoItems.GetAllTodoItems; 4 | 5 | public class GetAllTodoItemsQuery : IRequest> 6 | { 7 | } -------------------------------------------------------------------------------- /src/TodoList.Application/TodoItems/GetAllTodoItems/GetAllTodoItemsQueryHandler.cs: -------------------------------------------------------------------------------- 1 | using MediatR; 2 | using TodoList.Domain.TodoItems; 3 | 4 | namespace TodoList.Application.TodoItems.GetAllTodoItems; 5 | 6 | public class GetAllTodoItemsQueryHandler : IRequestHandler> 7 | { 8 | private readonly ITodoItemRepository _repository; 9 | 10 | public GetAllTodoItemsQueryHandler(ITodoItemRepository repository) 11 | { 12 | _repository = repository; 13 | } 14 | 15 | public async Task> Handle(GetAllTodoItemsQuery query, CancellationToken cancellationToken) 16 | { 17 | var todoItems = await _repository.GetAllAsync(); 18 | 19 | return todoItems.Select(todoItem => new TodoItemResponse 20 | { 21 | Id = todoItem.Id, 22 | Title = todoItem.Title, 23 | DueDate = todoItem.DueDate, 24 | IsCompleted = todoItem.IsCompleted, 25 | Priority = todoItem.Priority 26 | }).ToList(); 27 | } 28 | } -------------------------------------------------------------------------------- /src/TodoList.Application/TodoItems/GetTodoItem/GetTodoItemByIdQuery.cs: -------------------------------------------------------------------------------- 1 | using MediatR; 2 | 3 | namespace TodoList.Application.TodoItems.GetTodoItem; 4 | 5 | public class GetTodoItemByIdQuery : IRequest 6 | { 7 | public int Id { get; set; } 8 | } -------------------------------------------------------------------------------- /src/TodoList.Application/TodoItems/GetTodoItem/GetTodoItemByIdQueryHandler.cs: -------------------------------------------------------------------------------- 1 | using MediatR; 2 | using TodoList.Domain.TodoItems; 3 | 4 | namespace TodoList.Application.TodoItems.GetTodoItem; 5 | 6 | public class GetTodoItemByIdQueryHandler : IRequestHandler 7 | { 8 | private readonly ITodoItemRepository _repository; 9 | 10 | public GetTodoItemByIdQueryHandler(ITodoItemRepository repository) 11 | { 12 | _repository = repository; 13 | } 14 | 15 | public async Task Handle(GetTodoItemByIdQuery query, CancellationToken cancellationToken) 16 | { 17 | var todoItem = await _repository.GetByIdAsync(query.Id); 18 | if (todoItem == null) return null; 19 | 20 | return new TodoItemResponse() 21 | { 22 | Id = todoItem.Id, 23 | Title = todoItem.Title, 24 | DueDate = todoItem.DueDate, 25 | IsCompleted = todoItem.IsCompleted, 26 | Priority = todoItem.Priority // Assuming Priority is a public property on TodoItem 27 | }; 28 | } 29 | } -------------------------------------------------------------------------------- /src/TodoList.Application/TodoItems/TodoItemResponse.cs: -------------------------------------------------------------------------------- 1 | namespace TodoList.Application.TodoItems; 2 | 3 | public class TodoItemResponse 4 | { 5 | public int Id { get; set; } 6 | public string Title { get; set; } 7 | public DateOnly DueDate { get; set; } 8 | public bool IsCompleted { get; set; } 9 | public string Priority { get; set; } 10 | } -------------------------------------------------------------------------------- /src/TodoList.Application/TodoItems/UpdateTodoItem/UpdateTodoItemCommand.cs: -------------------------------------------------------------------------------- 1 | using MediatR; 2 | 3 | namespace TodoList.Application.TodoItems.UpdateTodoItem; 4 | 5 | public class UpdateTodoItemCommand : IRequest 6 | { 7 | public int Id { get; set; } 8 | public string Title { get; set; } 9 | public DateOnly DueDate { get; set; } 10 | public bool? IsCompleted { get; set; } 11 | } -------------------------------------------------------------------------------- /src/TodoList.Application/TodoItems/UpdateTodoItem/UpdateTodoItemCommandHandler.cs: -------------------------------------------------------------------------------- 1 | using MediatR; 2 | using TodoList.Domain.Abstractions; 3 | using TodoList.Domain.TodoItems; 4 | 5 | namespace TodoList.Application.TodoItems.UpdateTodoItem; 6 | 7 | public class UpdateTodoItemCommandHandler : IRequestHandler 8 | { 9 | private readonly ITodoItemRepository _repository; 10 | private readonly IUnitOfWork _unitOfWork; 11 | private readonly PrioritySuggestionService _priorityService; 12 | 13 | public UpdateTodoItemCommandHandler(ITodoItemRepository repository, IUnitOfWork unitOfWork, PrioritySuggestionService priorityService) 14 | { 15 | _repository = repository; 16 | _unitOfWork = unitOfWork; 17 | _priorityService = priorityService; 18 | } 19 | 20 | public async Task Handle(UpdateTodoItemCommand command, CancellationToken cancellationToken) 21 | { 22 | var todoItem = await _repository.GetByIdAsync(command.Id); 23 | if (todoItem == null) return false; 24 | 25 | todoItem.SetTitle(command.Title); 26 | todoItem.SetDueDate(command.DueDate); 27 | if (command.IsCompleted.HasValue && command.IsCompleted.Value) 28 | { 29 | todoItem.MarkAsCompleted(); 30 | } 31 | 32 | await _repository.UpdateAsync(todoItem); 33 | _unitOfWork.Commit(); 34 | 35 | return true; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/TodoList.Application/TodoList.Application.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net7.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/TodoList.Domain/Abstractions/BaseEntity.cs: -------------------------------------------------------------------------------- 1 | namespace TodoList.Domain.Abstractions; 2 | 3 | public abstract class BaseEntity 4 | { 5 | public int Id { get; protected set; } 6 | private List _domainEvents; 7 | public IReadOnlyCollection DomainEvents => _domainEvents.AsReadOnly(); 8 | 9 | protected void AddDomainEvent(IDomainEvent eventItem) 10 | { 11 | _domainEvents ??= new List(); 12 | _domainEvents.Add(eventItem); 13 | } 14 | 15 | public void ClearDomainEvents() 16 | { 17 | _domainEvents?.Clear(); 18 | } 19 | } -------------------------------------------------------------------------------- /src/TodoList.Domain/Abstractions/IDomainEvent.cs: -------------------------------------------------------------------------------- 1 | using MediatR; 2 | 3 | namespace TodoList.Domain.Abstractions; 4 | 5 | public interface IDomainEvent : INotification 6 | { 7 | } -------------------------------------------------------------------------------- /src/TodoList.Domain/Abstractions/IUnitOfWork.cs: -------------------------------------------------------------------------------- 1 | namespace TodoList.Domain.Abstractions; 2 | 3 | public interface IUnitOfWork : IDisposable 4 | { 5 | int Commit(); 6 | } 7 | -------------------------------------------------------------------------------- /src/TodoList.Domain/TodoItems/Events/TodoItemCompletedEvent.cs: -------------------------------------------------------------------------------- 1 | using TodoList.Domain.Abstractions; 2 | 3 | namespace TodoList.Domain.TodoItems.Events; 4 | 5 | public class TodoItemCompletedEvent : IDomainEvent 6 | { 7 | public TodoItemCompletedEvent(TodoItem item) 8 | { 9 | TodoItem = item; 10 | } 11 | 12 | public TodoItem TodoItem { get; } 13 | } 14 | -------------------------------------------------------------------------------- /src/TodoList.Domain/TodoItems/ITodoItemRepository.cs: -------------------------------------------------------------------------------- 1 | namespace TodoList.Domain.TodoItems; 2 | 3 | public interface ITodoItemRepository 4 | { 5 | Task GetByIdAsync(int id); 6 | Task> GetAllAsync(); 7 | Task AddAsync(TodoItem item); 8 | Task UpdateAsync(TodoItem item); 9 | Task DeleteAsync(int id); 10 | } 11 | -------------------------------------------------------------------------------- /src/TodoList.Domain/TodoItems/PrioritySuggestionService.cs: -------------------------------------------------------------------------------- 1 | namespace TodoList.Domain.TodoItems; 2 | 3 | public class PrioritySuggestionService 4 | { 5 | public string SuggestPriority(TodoItem todoItem) 6 | { 7 | // Convert DateOnly to DateTime (midnight of that date in UTC) 8 | DateTime dueDateTime = todoItem.DueDate.ToDateTime(TimeOnly.FromDateTime(DateTime.UtcNow)); 9 | 10 | // Calculate time left 11 | TimeSpan timeLeft = dueDateTime - DateTime.UtcNow; 12 | 13 | 14 | if (timeLeft.TotalDays <= 1) 15 | { 16 | return "High"; 17 | } 18 | else if (timeLeft.TotalDays <= 3) 19 | { 20 | return "Medium"; 21 | } 22 | else 23 | { 24 | return "Low"; 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/TodoList.Domain/TodoItems/TodoItem.cs: -------------------------------------------------------------------------------- 1 | using TodoList.Domain.Abstractions; 2 | using TodoList.Domain.TodoItems.Events; 3 | 4 | namespace TodoList.Domain.TodoItems; 5 | 6 | public class TodoItem : BaseEntity 7 | { 8 | public string Title { get; private set; } 9 | public DateOnly DueDate { get; private set; } 10 | public bool IsCompleted { get; private set; } 11 | public string Priority { get; private set; } 12 | 13 | private TodoItem() 14 | { 15 | // This empty constructor is required for Dapper materialization 16 | } 17 | 18 | public TodoItem(string title, DateOnly dueDate, PrioritySuggestionService priorityService) 19 | { 20 | SetTitle(title); 21 | SetDueDate(dueDate); 22 | IsCompleted = false; 23 | SetPriority(priorityService); 24 | } 25 | 26 | public void MarkAsCompleted() 27 | { 28 | IsCompleted = true; 29 | AddDomainEvent(new TodoItemCompletedEvent(this)); 30 | } 31 | 32 | public void SetTitle(string title) 33 | { 34 | if (string.IsNullOrWhiteSpace(title)) 35 | throw new ArgumentException("Title cannot be empty."); 36 | 37 | Title = title; 38 | } 39 | 40 | public void SetDueDate(DateOnly dueDate) 41 | { 42 | DueDate = dueDate; 43 | } 44 | 45 | private void SetPriority(PrioritySuggestionService priorityService) 46 | { 47 | Priority = priorityService.SuggestPriority(this); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/TodoList.Domain/TodoList.Domain.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net7.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/TodoList.Infrastructure/Data/DateOnlyHandler.cs: -------------------------------------------------------------------------------- 1 | using Dapper; 2 | using System.Data; 3 | 4 | namespace TodoList.Infrastructure.Data; 5 | 6 | internal sealed class DateOnlyHandler : SqlMapper.TypeHandler 7 | { 8 | public override DateOnly Parse(object value) => DateOnly.FromDateTime((DateTime)value); 9 | 10 | public override void SetValue(IDbDataParameter parameter, DateOnly value) 11 | { 12 | parameter.DbType = DbType.Date; 13 | parameter.Value = value; 14 | } 15 | } -------------------------------------------------------------------------------- /src/TodoList.Infrastructure/Data/MySqlConnectionFactory.cs: -------------------------------------------------------------------------------- 1 | using MySql.Data.MySqlClient; 2 | using System.Data; 3 | 4 | namespace TodoList.Infrastructure.Data; 5 | 6 | public class MySqlConnectionFactory 7 | { 8 | private readonly string _connectionString; 9 | 10 | public MySqlConnectionFactory(string connectionString) 11 | { 12 | _connectionString = connectionString; 13 | } 14 | 15 | public IDbConnection CreateConnection() 16 | { 17 | return new MySqlConnection(_connectionString); 18 | } 19 | } -------------------------------------------------------------------------------- /src/TodoList.Infrastructure/DependencyInjection.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using Dapper; 3 | using Microsoft.Extensions.Configuration; 4 | using Microsoft.Extensions.DependencyInjection; 5 | using TodoList.Application.Context; 6 | using TodoList.Domain.Abstractions; 7 | using TodoList.Infrastructure.Data; 8 | using TodoList.Infrastructure.Repositories; 9 | 10 | namespace TodoList.Infrastructure; 11 | 12 | public static class DependencyInjection 13 | { 14 | public static IServiceCollection AddInfrastructure(this IServiceCollection services, IConfiguration configuration) 15 | { 16 | var connectionString = 17 | configuration.GetConnectionString("DefaultConnection") ?? 18 | throw new ArgumentNullException(nameof(configuration)); 19 | 20 | // Register repositories using reflection based on naming convention 21 | var repositoryTypes = Assembly.GetAssembly(typeof(TodoItemRepository)) // Assuming TodoItemRepository is representative of the assembly containing all repositories 22 | ?.GetTypes() 23 | .Where(t => t.IsClass && !t.IsAbstract && t.Name.EndsWith("Repository")) 24 | .ToList(); 25 | 26 | foreach (var type in repositoryTypes) 27 | { 28 | var interfaceType = type.GetInterfaces().FirstOrDefault(i => i.Name == "I" + type.Name); 29 | if (interfaceType != null) 30 | { 31 | services.AddScoped(interfaceType, type); 32 | } 33 | } 34 | 35 | services.AddTransient(c => new DapperUnitOfWork(connectionString)); 36 | services.AddSingleton(new MySqlConnectionFactory(connectionString)); 37 | SqlMapper.AddTypeHandler(new DateOnlyHandler()); 38 | 39 | return services; 40 | } 41 | } -------------------------------------------------------------------------------- /src/TodoList.Infrastructure/Repositories/TodoItemRepository.cs: -------------------------------------------------------------------------------- 1 | using TodoList.Infrastructure.Data; 2 | 3 | namespace TodoList.Infrastructure.Repositories; 4 | 5 | using Dapper; 6 | using System.Data; 7 | using TodoList.Domain.TodoItems; 8 | 9 | public class TodoItemRepository : ITodoItemRepository 10 | { 11 | private readonly IDbConnection _connection; 12 | 13 | public TodoItemRepository(MySqlConnectionFactory connectionFactory) 14 | { 15 | _connection = connectionFactory.CreateConnection(); 16 | } 17 | 18 | public async Task GetByIdAsync(int id) 19 | { 20 | const string sql = "SELECT * FROM TodoItems WHERE Id = @Id"; 21 | return await _connection.QuerySingleOrDefaultAsync(sql, new { Id = id }); 22 | } 23 | 24 | public async Task> GetAllAsync() 25 | { 26 | const string sql = "SELECT * FROM TodoItems"; 27 | var todoItems = await _connection.QueryAsync(sql); 28 | return todoItems.ToList(); 29 | } 30 | 31 | public async Task AddAsync(TodoItem item) 32 | { 33 | const string sql = "INSERT INTO TodoItems (Title, DueDate, IsCompleted, Priority) VALUES (@Title, @DueDate, @IsCompleted, @Priority)"; 34 | await _connection.ExecuteAsync(sql, item); 35 | } 36 | 37 | public async Task UpdateAsync(TodoItem item) 38 | { 39 | const string sql = "UPDATE TodoItems SET Title = @Title, DueDate = @DueDate, IsCompleted = @IsCompleted, Priority = @Priority WHERE Id = @Id"; 40 | await _connection.ExecuteAsync(sql, item); 41 | } 42 | 43 | public async Task DeleteAsync(int id) 44 | { 45 | const string sql = "DELETE FROM TodoItems WHERE Id = @Id"; 46 | await _connection.ExecuteAsync(sql, new { Id = id }); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/TodoList.Infrastructure/TodoList.Infrastructure.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net7.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /test/TodoList.Application.UnitTests/GlobalUsings.cs: -------------------------------------------------------------------------------- 1 | global using Xunit; -------------------------------------------------------------------------------- /test/TodoList.Application.UnitTests/TodoItems/Commands/CreateTodoItemCommandHandlerTests.cs: -------------------------------------------------------------------------------- 1 | using Moq; 2 | using TodoList.Application.TodoItems.CreateTodoItem; 3 | using TodoList.Domain.Abstractions; 4 | using TodoList.Domain.TodoItems; 5 | using TodoList.Infrastructure.Repositories; 6 | 7 | namespace TodoList.Application.UnitTests.TodoItems.Commands; 8 | 9 | public class CreateTodoItemCommandHandlerTests 10 | { 11 | [Fact] 12 | public async Task Handle_ShouldPersistTodoItem() 13 | { 14 | // Arrange 15 | var mockUnitOfWork = new Mock(); 16 | var mockRepository = new Mock(); 17 | 18 | mockRepository.Setup(r => r.AddAsync(It.IsAny())).Returns(Task.CompletedTask); 19 | 20 | // You can either use a real PrioritySuggestionService or mock it. 21 | // If you just want to test the handler logic, it's often easier to use the real service if it doesn't have external dependencies. 22 | var priorityService = new PrioritySuggestionService(); 23 | 24 | var handler = new CreateTodoItemCommandHandler(mockRepository.Object, mockUnitOfWork.Object, priorityService); 25 | var command = new CreateTodoItemCommand 26 | { 27 | Title = "Test Task", 28 | DueDate = DateOnly.MinValue 29 | }; 30 | 31 | // Act 32 | await handler.Handle(command, CancellationToken.None); 33 | 34 | // Assert 35 | mockRepository.Verify(r => r.AddAsync(It.IsAny()), Times.Once()); 36 | mockUnitOfWork.Verify(u => u.Commit(), Times.Once()); 37 | } 38 | } -------------------------------------------------------------------------------- /test/TodoList.Application.UnitTests/TodoItems/Queries/GetTodoItemByIdQueryHandlerTests.cs: -------------------------------------------------------------------------------- 1 | using Moq; 2 | using TodoList.Application.TodoItems; 3 | using TodoList.Application.TodoItems.GetTodoItem; 4 | using TodoList.Domain.TodoItems; 5 | 6 | namespace TodoList.Application.UnitTests.TodoItems.Queries; 7 | 8 | public class GetTodoItemByIdQueryHandlerTests 9 | { 10 | [Fact] 11 | public async Task Handle_ShouldReturnCorrectTodoItem() 12 | { 13 | // Arrange 14 | var todoItem = new TodoItem("Test", DateOnly.MinValue, new PrioritySuggestionService()); 15 | var todoItemDto = new TodoItemResponse 16 | { 17 | Id = todoItem.Id, 18 | Title = todoItem.Title, 19 | DueDate = todoItem.DueDate, 20 | IsCompleted = todoItem.IsCompleted, 21 | Priority = todoItem.Priority 22 | }; 23 | 24 | var mockRepository = new Mock(); 25 | 26 | mockRepository.Setup(r => r.GetByIdAsync(It.IsAny())).ReturnsAsync(todoItem); 27 | 28 | var handler = new GetTodoItemByIdQueryHandler(mockRepository.Object); 29 | 30 | var query = new GetTodoItemByIdQuery 31 | { 32 | Id = 1 33 | }; 34 | 35 | // Act 36 | var result = await handler.Handle(query, CancellationToken.None); 37 | 38 | // Assert 39 | Assert.Equal(todoItemDto.Title, result.Title); 40 | Assert.Equal(todoItemDto.DueDate, result.DueDate); 41 | Assert.Equal(todoItemDto.IsCompleted, result.IsCompleted); 42 | Assert.Equal(todoItemDto.Priority, result.Priority); 43 | } 44 | } -------------------------------------------------------------------------------- /test/TodoList.Application.UnitTests/TodoList.Application.UnitTests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net7.0 5 | enable 6 | enable 7 | 8 | false 9 | true 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | runtime; build; native; contentfiles; analyzers; buildtransitive 18 | all 19 | 20 | 21 | runtime; build; native; contentfiles; analyzers; buildtransitive 22 | all 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /test/TodoList.ArchitectureTests/BaseTest.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using TodoList.Application.Context; 3 | using TodoList.Domain.Abstractions; 4 | using TodoList.Infrastructure.Data; 5 | 6 | namespace TodoList.ArchitectureTests; 7 | 8 | public class BaseTest 9 | { 10 | protected static Assembly ApplicationAssembly => typeof(DapperUnitOfWork).Assembly; 11 | protected static Assembly DomainAssembly => typeof(BaseEntity).Assembly; 12 | protected static Assembly InfrastructureAssembly => typeof(MySqlConnectionFactory).Assembly; 13 | } -------------------------------------------------------------------------------- /test/TodoList.ArchitectureTests/GlobalUsings.cs: -------------------------------------------------------------------------------- 1 | global using Xunit; -------------------------------------------------------------------------------- /test/TodoList.ArchitectureTests/LayerTests.cs: -------------------------------------------------------------------------------- 1 | using FluentAssertions; 2 | using NetArchTest.Rules; 3 | 4 | namespace TodoList.ArchitectureTests; 5 | 6 | public class LayerTests : BaseTest 7 | { 8 | [Fact] 9 | public void DomainLayer_Should_NotHaveDependencyOn_ApplicationLayer() 10 | { 11 | var result = Types.InAssembly(DomainAssembly) 12 | .Should() 13 | .NotHaveDependencyOn(ApplicationAssembly.GetName().Name) 14 | .GetResult(); 15 | 16 | result.IsSuccessful.Should().BeTrue(); 17 | } 18 | 19 | [Fact] 20 | public void DomainLayer_Should_NotHaveDependencyOn_InfrastructureLayer() 21 | { 22 | var result = Types.InAssembly(DomainAssembly) 23 | .Should() 24 | .NotHaveDependencyOn(ApplicationAssembly.GetName().Name) 25 | .GetResult(); 26 | 27 | result.IsSuccessful.Should().BeTrue(); 28 | } 29 | 30 | [Fact] 31 | public void ApplicationLayer_Should_NotHaveDependencyOn_InfrastructureLayer() 32 | { 33 | var result = Types.InAssembly(ApplicationAssembly) 34 | .Should() 35 | .NotHaveDependencyOn(InfrastructureAssembly.GetName().Name) 36 | .GetResult(); 37 | 38 | result.IsSuccessful.Should().BeTrue(); 39 | } 40 | } -------------------------------------------------------------------------------- /test/TodoList.ArchitectureTests/TodoList.ArchitectureTests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net7.0 5 | enable 6 | enable 7 | 8 | false 9 | true 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | runtime; build; native; contentfiles; analyzers; buildtransitive 19 | all 20 | 21 | 22 | runtime; build; native; contentfiles; analyzers; buildtransitive 23 | all 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /test/TodoList.Domain.UnitTests/GlobalUsings.cs: -------------------------------------------------------------------------------- 1 | global using Xunit; -------------------------------------------------------------------------------- /test/TodoList.Domain.UnitTests/TodoItems/PrioritySuggestionServiceTests.cs: -------------------------------------------------------------------------------- 1 | using TodoList.Domain.TodoItems; 2 | 3 | namespace TodoList.Domain.UnitTests.TodoItems; 4 | 5 | public class PrioritySuggestionServiceTests 6 | { 7 | [Theory] 8 | [InlineData(5, "Low")] 9 | [InlineData(0, "High")] 10 | [InlineData(1, "High")] 11 | [InlineData(2, "Medium")] 12 | public void SuggestPriority_ShouldReturnExpectedPriority(int daysUntilDue, string expectedPriority) 13 | { 14 | // Arrange 15 | var service = new PrioritySuggestionService(); 16 | var dueDate = DateOnly.FromDateTime(DateTime.UtcNow.AddDays(daysUntilDue)); 17 | var todo = new TodoItem("Test task", dueDate, service); 18 | 19 | // Act 20 | var priority = service.SuggestPriority(todo); 21 | 22 | // Assert 23 | Assert.Equal(expectedPriority, priority); 24 | } 25 | } -------------------------------------------------------------------------------- /test/TodoList.Domain.UnitTests/TodoItems/TodoItemTests.cs: -------------------------------------------------------------------------------- 1 | using FluentAssertions; 2 | using Moq; 3 | using TodoList.Domain.TodoItems; 4 | using TodoList.Domain.TodoItems.Events; 5 | 6 | namespace TodoList.Domain.UnitTests.TodoItems; 7 | 8 | public class TodoItemTests 9 | { 10 | [Fact] 11 | public void MarkAsCompleted_Should_Raise_TodoItemCompletedEvent() 12 | { 13 | // Arrange 14 | var todoItem = new TodoItem("Test", DateOnly.FromDateTime(DateTime.UtcNow), new PrioritySuggestionService()); 15 | 16 | // Act 17 | todoItem.MarkAsCompleted(); 18 | 19 | // Assert 20 | var todoItemCompletedEvent = todoItem.DomainEvents.OfType().SingleOrDefault(); 21 | todoItemCompletedEvent.Should().NotBeNull(); 22 | todoItemCompletedEvent!.TodoItem.Should().Be(todoItem); 23 | } 24 | } -------------------------------------------------------------------------------- /test/TodoList.Domain.UnitTests/TodoList.Domain.UnitTests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net7.0 5 | enable 6 | enable 7 | 8 | false 9 | true 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | runtime; build; native; contentfiles; analyzers; buildtransitive 19 | all 20 | 21 | 22 | runtime; build; native; contentfiles; analyzers; buildtransitive 23 | all 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | --------------------------------------------------------------------------------