├── .gitattributes
├── .gitignore
├── Core
└── Core.csproj
├── PlacementTest.Application
├── Common
│ ├── Behaviors
│ │ └── ValidationBehavior.cs
│ └── Exceptions
│ │ └── SystemExceptions.cs
├── Features
│ └── TestTakersFeatures
│ │ ├── Add
│ │ ├── AddTestTakerHandler.cs
│ │ ├── AddTestTakerMapper.cs
│ │ ├── AddTestTakerRequest.cs
│ │ ├── AddTestTakerResponse.cs
│ │ └── AddTestTakerValidator.cs
│ │ └── Get
│ │ ├── GetAllTestTakersHandler.cs
│ │ ├── GetAllTestTakersMapper.cs
│ │ ├── GetAllTestTakersRequest.cs
│ │ └── GetAllTestTakersResponse.cs
├── PlacementTest.Application.csproj
├── Repository
│ ├── IBaseRepository.cs
│ ├── IUnitOfWork.cs
│ └── TestTakersRepository
│ │ └── ITestTakerRepository.cs
└── ServiceExtensions.cs
├── PlacementTest.Domain
├── Common
│ └── BaseEntity.cs
├── Entities
│ └── TestTakers.cs
└── PlacementTest.Domain.csproj
├── PlacementTest.Persistence
├── Context
│ └── PlacementTestContext.cs
├── Migrations
│ ├── 20230609222851_InitDb.Designer.cs
│ ├── 20230609222851_InitDb.cs
│ └── PlacementTestContextModelSnapshot.cs
├── PlacementTest.Persistence.csproj
├── Repository
│ ├── BaseRepository.cs
│ ├── TestTakersRepository
│ │ └── TestTakerRepository.cs
│ └── UnitOfWork.cs
└── ServiceExtensions.cs
├── PlacementTest.WebAPI
├── Controllers
│ ├── Base
│ │ └── BaseController.cs
│ └── TestTakerController.cs
├── Extensions
│ ├── ApiBehaviorExtensions.cs
│ ├── CorsPolicyExtensions.cs
│ └── ErrorHandlerExtensions.cs
├── PlacementTest.WebAPI.csproj
├── Program.cs
├── Properties
│ └── launchSettings.json
├── appsettings.Development.json
└── appsettings.json
├── PlacementTest.sln
└── 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
--------------------------------------------------------------------------------
/Core/Core.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 | enable
6 | enable
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/PlacementTest.Application/Common/Behaviors/ValidationBehavior.cs:
--------------------------------------------------------------------------------
1 | using FluentValidation;
2 | using MediatR;
3 | using PlacementTest.Application.Common.Exceptions;
4 |
5 | namespace PlacementTest.Application.Common.Behaviors
6 | {
7 | public sealed class ValidationBehavior : IPipelineBehavior
8 | where TRequest : IRequest
9 | {
10 | private readonly IEnumerable> _validators;
11 |
12 | public ValidationBehavior(IEnumerable> validators)
13 | {
14 | _validators = validators;
15 | }
16 |
17 | public async Task Handle(TRequest request, RequestHandlerDelegate next, CancellationToken cancellationToken)
18 | {
19 | if (!_validators.Any()) return await next();
20 |
21 | var context = new ValidationContext(request);
22 |
23 | var errors = _validators
24 | .Select(x => x.Validate(context))
25 | .SelectMany(x => x.Errors)
26 | .Where(x => x != null)
27 | .Select(x => x.ErrorMessage)
28 | .Distinct()
29 | .ToArray();
30 |
31 | if (errors.Any())
32 | throw new BadRequestException(errors);
33 |
34 | return await next();
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/PlacementTest.Application/Common/Exceptions/SystemExceptions.cs:
--------------------------------------------------------------------------------
1 | namespace PlacementTest.Application.Common.Exceptions
2 | {
3 | public class BadRequestException : Exception
4 | {
5 | public BadRequestException(string message) : base(message)
6 | {
7 | }
8 |
9 | public BadRequestException(string[] errors) : base("Multiple errors occurred. See error details.")
10 | {
11 | Errors = errors;
12 | }
13 |
14 | public string[] Errors { get; set; }
15 | }
16 | public class NoDataFoundException : Exception
17 | {
18 | public NoDataFoundException(string message) : base(message)
19 | {
20 | }
21 | }
22 | public class SocketException : Exception
23 | {
24 | public SocketException(string message) : base(message)
25 | {
26 | }
27 | }
28 | public class UserAlreadyExistsException : Exception
29 | {
30 | public UserAlreadyExistsException() : base("User already exists.")
31 | {
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/PlacementTest.Application/Features/TestTakersFeatures/Add/AddTestTakerHandler.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using MediatR;
3 | using PlacementTest.Application.Repository;
4 | using PlacementTest.Application.Repository.TestTakersRepository;
5 | using PlacementTest.Domain.Entities;
6 | using System;
7 | using System.Collections.Generic;
8 | using System.Linq;
9 | using System.Text;
10 | using System.Threading.Tasks;
11 |
12 | namespace PlacementTest.Application.Features.TestTakersFeatures
13 | {
14 | public sealed class AddTestTakerHandler : IRequestHandler
15 | {
16 | private readonly IUnitOfWork _unitOfWork;
17 | private readonly ITestTakerRepository _testTakerRepository;
18 | private readonly IMapper _mapper;
19 |
20 | public AddTestTakerHandler(IUnitOfWork unitOfWork,
21 | ITestTakerRepository testTakerRepository, IMapper mapper)
22 | {
23 | _unitOfWork = unitOfWork;
24 | _testTakerRepository = testTakerRepository;
25 | _mapper = mapper;
26 | }
27 |
28 | public async Task Handle(AddTestTakerRequest request,
29 | CancellationToken cancellationToken)
30 | {
31 | var user = _mapper.Map(request);
32 | _testTakerRepository.Create(user);
33 | await _unitOfWork.Save(cancellationToken);
34 |
35 | return _mapper.Map(user);
36 | }
37 |
38 |
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/PlacementTest.Application/Features/TestTakersFeatures/Add/AddTestTakerMapper.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using PlacementTest.Domain.Entities;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 |
9 | namespace PlacementTest.Application.Features.TestTakersFeatures
10 | {
11 | public sealed class AddTestTakerMapper : Profile
12 | {
13 | public AddTestTakerMapper()
14 | {
15 | CreateMap();
16 | CreateMap();
17 | }
18 | }
19 | }
--------------------------------------------------------------------------------
/PlacementTest.Application/Features/TestTakersFeatures/Add/AddTestTakerRequest.cs:
--------------------------------------------------------------------------------
1 | using MediatR;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace PlacementTest.Application.Features.TestTakersFeatures
9 | {
10 | public sealed record AddTestTakerRequest(string Email, string FirstName, string LastName, string BannerID, string FormNumber) : IRequest;
11 | }
12 |
--------------------------------------------------------------------------------
/PlacementTest.Application/Features/TestTakersFeatures/Add/AddTestTakerResponse.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace PlacementTest.Application.Features.TestTakersFeatures
8 | {
9 | public sealed record class AddTestTakerResponse
10 | {
11 | public Guid ID { get; set; }
12 | public string BannerID { get; set; }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/PlacementTest.Application/Features/TestTakersFeatures/Add/AddTestTakerValidator.cs:
--------------------------------------------------------------------------------
1 | using FluentValidation;
2 |
3 | namespace PlacementTest.Application.Features.TestTakersFeatures
4 | {
5 | public sealed class AddTestTakerValidator : AbstractValidator
6 | {
7 | public AddTestTakerValidator()
8 | {
9 | RuleFor(x => x.Email).NotEmpty().MaximumLength(50).EmailAddress();
10 | RuleFor(x => x.FirstName).NotEmpty().MinimumLength(2).MaximumLength(50);
11 | RuleFor(x => x.LastName).NotEmpty().MinimumLength(2).MaximumLength(50);
12 | RuleFor(x => x.BannerID).NotEmpty().MinimumLength(2).MaximumLength(20);
13 | RuleFor(x => x.FormNumber).NotEmpty().MinimumLength(2).MaximumLength(35);
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/PlacementTest.Application/Features/TestTakersFeatures/Get/GetAllTestTakersHandler.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using MediatR;
3 | using PlacementTest.Application.Repository.TestTakersRepository;
4 | using System;
5 | using System.Collections.Generic;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 |
10 | namespace PlacementTest.Application.Features.TestTakersFeatures.Get
11 | {
12 | public sealed class GetAllTestTakersHandler : IRequestHandler>
13 | {
14 | private readonly ITestTakerRepository _TestTakerRepository;
15 | private readonly IMapper _mapper;
16 |
17 | public GetAllTestTakersHandler(ITestTakerRepository TestTakersRepository, IMapper mapper)
18 | {
19 | _TestTakerRepository = TestTakersRepository;
20 | _mapper = mapper;
21 | }
22 |
23 | public async Task> Handle(GetAllTestTakersRequest request, CancellationToken cancellationToken)
24 | {
25 | var TestTakerss = await _TestTakerRepository.GetAll(cancellationToken);
26 | return _mapper.Map>(TestTakerss);
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/PlacementTest.Application/Features/TestTakersFeatures/Get/GetAllTestTakersMapper.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using PlacementTest.Domain.Entities;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 |
9 | namespace PlacementTest.Application.Features.TestTakersFeatures.Get
10 | {
11 | public sealed class GetAllTestTakersMapper : Profile
12 | {
13 | public GetAllTestTakersMapper()
14 | {
15 | CreateMap();
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/PlacementTest.Application/Features/TestTakersFeatures/Get/GetAllTestTakersRequest.cs:
--------------------------------------------------------------------------------
1 | using MediatR;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace PlacementTest.Application.Features.TestTakersFeatures.Get
9 | {
10 | public sealed record GetAllTestTakersRequest : IRequest>;
11 | }
12 |
--------------------------------------------------------------------------------
/PlacementTest.Application/Features/TestTakersFeatures/Get/GetAllTestTakersResponse.cs:
--------------------------------------------------------------------------------
1 | namespace PlacementTest.Application.Features.TestTakersFeatures.Get
2 | {
3 | public sealed record GetAllTestTakersResponse
4 | {
5 | public Guid ID { get; set; }
6 | public string Email { get; set; }
7 | public string FirstName { get; set; }
8 | public string LastName { get; set; }
9 | public string FormNumber { get; set; }
10 | public string BannerID { get; set; }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/PlacementTest.Application/PlacementTest.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 |
--------------------------------------------------------------------------------
/PlacementTest.Application/Repository/IBaseRepository.cs:
--------------------------------------------------------------------------------
1 | using PlacementTest.Domain.Common;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace PlacementTest.Application.Repository
9 | {
10 | public interface IBaseRepository where T : BaseEntity
11 | {
12 | void Create(T entity);
13 | void Update(T entity);
14 | void Delete(T entity);
15 | Task Get(Guid id, CancellationToken cancellationToken);
16 | Task> GetAll(CancellationToken cancellationToken);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/PlacementTest.Application/Repository/IUnitOfWork.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace PlacementTest.Application.Repository
8 | {
9 | public interface IUnitOfWork
10 | {
11 | Task Save(CancellationToken cancellationToken);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/PlacementTest.Application/Repository/TestTakersRepository/ITestTakerRepository.cs:
--------------------------------------------------------------------------------
1 | using PlacementTest.Domain.Entities;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace PlacementTest.Application.Repository.TestTakersRepository
9 | {
10 | public interface ITestTakerRepository : IBaseRepository
11 | {
12 | Task GetByID(string BannerID, CancellationToken cancellationToken);
13 |
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/PlacementTest.Application/ServiceExtensions.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using PlacementTest.Application.Common.Behaviors;
3 | using MediatR;
4 | using Microsoft.Extensions.DependencyInjection;
5 | using FluentValidation;
6 |
7 | namespace PlacementTest.Application
8 | {
9 | public static class ServiceExtensions
10 | {
11 | public static void ConfigureApplication(this IServiceCollection services)
12 | {
13 | services.AddAutoMapper(Assembly.GetExecutingAssembly());
14 | services.AddMediatR(cfg => cfg.RegisterServicesFromAssembly(Assembly.GetExecutingAssembly()));
15 | services.AddValidatorsFromAssembly(Assembly.GetExecutingAssembly());
16 | services.AddTransient(typeof(IPipelineBehavior<,>), typeof(ValidationBehavior<,>));
17 | }
18 | }
19 | }
--------------------------------------------------------------------------------
/PlacementTest.Domain/Common/BaseEntity.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel.DataAnnotations;
2 | using System.ComponentModel.DataAnnotations.Schema;
3 |
4 | namespace PlacementTest.Domain.Common
5 | {
6 | public class BaseEntity
7 | {
8 | [Key]
9 | [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
10 | public Guid ID { get; set; }
11 | public DateTimeOffset DateCreated { get; set; } = DateTimeOffset.Now;
12 | public DateTimeOffset? DateUpdated { get; set; }
13 | public DateTimeOffset? DateDeleted { get; set; }
14 | public Guid UserID { get; set; }
15 | public bool IsDeleted { get; set; } = false;
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/PlacementTest.Domain/Entities/TestTakers.cs:
--------------------------------------------------------------------------------
1 | using PlacementTest.Domain.Common;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace PlacementTest.Domain.Entities
9 | {
10 | public class TestTakers : BaseEntity
11 | {
12 | public string Email { get; set; }
13 | public string FirstName { get; set; }
14 | public string LastName { get; set; }
15 | public string FormNumber { get; set; }
16 | public string BannerID { get; set; }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/PlacementTest.Domain/PlacementTest.Domain.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 | enable
6 | enable
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/PlacementTest.Persistence/Context/PlacementTestContext.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore;
2 | using PlacementTest.Domain.Entities;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 |
9 | namespace PlacementTest.Persistence.Context
10 | {
11 | public class PlacementTestContext : DbContext
12 | {
13 | public PlacementTestContext(DbContextOptions options) : base(options)
14 | {
15 | }
16 |
17 | public DbSet TestTakers { get; set; }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/PlacementTest.Persistence/Migrations/20230609222851_InitDb.Designer.cs:
--------------------------------------------------------------------------------
1 | //
2 | using System;
3 | using Microsoft.EntityFrameworkCore;
4 | using Microsoft.EntityFrameworkCore.Infrastructure;
5 | using Microsoft.EntityFrameworkCore.Metadata;
6 | using Microsoft.EntityFrameworkCore.Migrations;
7 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
8 | using PlacementTest.Persistence.Context;
9 |
10 | #nullable disable
11 |
12 | namespace PlacementTest.Persistence.Migrations
13 | {
14 | [DbContext(typeof(PlacementTestContext))]
15 | [Migration("20230609222851_InitDb")]
16 | partial class InitDb
17 | {
18 | ///
19 | protected override void BuildTargetModel(ModelBuilder modelBuilder)
20 | {
21 | #pragma warning disable 612, 618
22 | modelBuilder
23 | .HasAnnotation("ProductVersion", "7.0.5")
24 | .HasAnnotation("Relational:MaxIdentifierLength", 128);
25 |
26 | SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
27 |
28 | modelBuilder.Entity("PlacementTest.Domain.Entities.TestTakers", b =>
29 | {
30 | b.Property("ID")
31 | .ValueGeneratedOnAdd()
32 | .HasColumnType("uniqueidentifier");
33 |
34 | b.Property("BannerID")
35 | .IsRequired()
36 | .HasColumnType("nvarchar(max)");
37 |
38 | b.Property("DateCreated")
39 | .HasColumnType("datetimeoffset");
40 |
41 | b.Property("DateDeleted")
42 | .HasColumnType("datetimeoffset");
43 |
44 | b.Property("DateUpdated")
45 | .HasColumnType("datetimeoffset");
46 |
47 | b.Property("Email")
48 | .IsRequired()
49 | .HasColumnType("nvarchar(max)");
50 |
51 | b.Property("FirstName")
52 | .IsRequired()
53 | .HasColumnType("nvarchar(max)");
54 |
55 | b.Property("FormNumber")
56 | .IsRequired()
57 | .HasColumnType("nvarchar(max)");
58 |
59 | b.Property("IsDeleted")
60 | .HasColumnType("bit");
61 |
62 | b.Property("LastName")
63 | .IsRequired()
64 | .HasColumnType("nvarchar(max)");
65 |
66 | b.Property("UserID")
67 | .HasColumnType("uniqueidentifier");
68 |
69 | b.HasKey("ID");
70 |
71 | b.ToTable("TestTakers");
72 | });
73 | #pragma warning restore 612, 618
74 | }
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/PlacementTest.Persistence/Migrations/20230609222851_InitDb.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.EntityFrameworkCore.Migrations;
3 |
4 | #nullable disable
5 |
6 | namespace PlacementTest.Persistence.Migrations
7 | {
8 | ///
9 | public partial class InitDb : Migration
10 | {
11 | ///
12 | protected override void Up(MigrationBuilder migrationBuilder)
13 | {
14 | migrationBuilder.CreateTable(
15 | name: "TestTakers",
16 | columns: table => new
17 | {
18 | ID = table.Column(type: "uniqueidentifier", nullable: false),
19 | Email = table.Column(type: "nvarchar(max)", nullable: false),
20 | FirstName = table.Column(type: "nvarchar(max)", nullable: false),
21 | LastName = table.Column(type: "nvarchar(max)", nullable: false),
22 | FormNumber = table.Column(type: "nvarchar(max)", nullable: false),
23 | BannerID = table.Column(type: "nvarchar(max)", nullable: false),
24 | DateCreated = table.Column(type: "datetimeoffset", nullable: false),
25 | DateUpdated = table.Column(type: "datetimeoffset", nullable: true),
26 | DateDeleted = table.Column(type: "datetimeoffset", nullable: true),
27 | UserID = table.Column(type: "uniqueidentifier", nullable: false),
28 | IsDeleted = table.Column(type: "bit", nullable: false)
29 | },
30 | constraints: table =>
31 | {
32 | table.PrimaryKey("PK_TestTakers", x => x.ID);
33 | });
34 | }
35 |
36 | ///
37 | protected override void Down(MigrationBuilder migrationBuilder)
38 | {
39 | migrationBuilder.DropTable(
40 | name: "TestTakers");
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/PlacementTest.Persistence/Migrations/PlacementTestContextModelSnapshot.cs:
--------------------------------------------------------------------------------
1 | //
2 | using System;
3 | using Microsoft.EntityFrameworkCore;
4 | using Microsoft.EntityFrameworkCore.Infrastructure;
5 | using Microsoft.EntityFrameworkCore.Metadata;
6 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
7 | using PlacementTest.Persistence.Context;
8 |
9 | #nullable disable
10 |
11 | namespace PlacementTest.Persistence.Migrations
12 | {
13 | [DbContext(typeof(PlacementTestContext))]
14 | partial class PlacementTestContextModelSnapshot : ModelSnapshot
15 | {
16 | protected override void BuildModel(ModelBuilder modelBuilder)
17 | {
18 | #pragma warning disable 612, 618
19 | modelBuilder
20 | .HasAnnotation("ProductVersion", "7.0.5")
21 | .HasAnnotation("Relational:MaxIdentifierLength", 128);
22 |
23 | SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
24 |
25 | modelBuilder.Entity("PlacementTest.Domain.Entities.TestTakers", b =>
26 | {
27 | b.Property("ID")
28 | .ValueGeneratedOnAdd()
29 | .HasColumnType("uniqueidentifier");
30 |
31 | b.Property("BannerID")
32 | .IsRequired()
33 | .HasColumnType("nvarchar(max)");
34 |
35 | b.Property("DateCreated")
36 | .HasColumnType("datetimeoffset");
37 |
38 | b.Property("DateDeleted")
39 | .HasColumnType("datetimeoffset");
40 |
41 | b.Property("DateUpdated")
42 | .HasColumnType("datetimeoffset");
43 |
44 | b.Property("Email")
45 | .IsRequired()
46 | .HasColumnType("nvarchar(max)");
47 |
48 | b.Property("FirstName")
49 | .IsRequired()
50 | .HasColumnType("nvarchar(max)");
51 |
52 | b.Property("FormNumber")
53 | .IsRequired()
54 | .HasColumnType("nvarchar(max)");
55 |
56 | b.Property("IsDeleted")
57 | .HasColumnType("bit");
58 |
59 | b.Property("LastName")
60 | .IsRequired()
61 | .HasColumnType("nvarchar(max)");
62 |
63 | b.Property("UserID")
64 | .HasColumnType("uniqueidentifier");
65 |
66 | b.HasKey("ID");
67 |
68 | b.ToTable("TestTakers");
69 | });
70 | #pragma warning restore 612, 618
71 | }
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/PlacementTest.Persistence/PlacementTest.Persistence.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 | enable
6 | enable
7 |
8 |
9 |
10 |
11 |
12 |
13 | all
14 | runtime; build; native; contentfiles; analyzers; buildtransitive
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/PlacementTest.Persistence/Repository/BaseRepository.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore;
2 | using PlacementTest.Application.Repository;
3 | using PlacementTest.Domain.Common;
4 | using PlacementTest.Persistence.Context;
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Linq;
8 | using System.Text;
9 | using System.Threading.Tasks;
10 |
11 | namespace PlacementTest.Persistence.Repository
12 | {
13 | public class BaseRepository : IBaseRepository where T : BaseEntity
14 | {
15 | protected readonly PlacementTestContext Context;
16 |
17 | public BaseRepository(PlacementTestContext context)
18 | {
19 | Context = context;
20 | }
21 |
22 | public void Create(T entity)
23 | {
24 | Context.Add(entity);
25 | }
26 |
27 | public void Update(T entity)
28 | {
29 | Context.Update(entity);
30 | }
31 |
32 | public void Delete(T entity)
33 | {
34 | entity.DateCreated = DateTimeOffset.UtcNow;
35 | Context.Update(entity);
36 | }
37 |
38 | public Task Get(Guid id, CancellationToken cancellationToken)
39 | {
40 | return Context.Set().FirstOrDefaultAsync(x => x.ID == id, cancellationToken);
41 | }
42 |
43 | public Task> GetAll(CancellationToken cancellationToken)
44 | {
45 | return Context.Set().ToListAsync(cancellationToken);
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/PlacementTest.Persistence/Repository/TestTakersRepository/TestTakerRepository.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore;
2 | using PlacementTest.Application.Repository.TestTakersRepository;
3 | using PlacementTest.Domain.Entities;
4 | using PlacementTest.Persistence.Context;
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Linq;
8 | using System.Text;
9 | using System.Threading.Tasks;
10 |
11 | namespace PlacementTest.Persistence.Repository.TestTakersRepository
12 | {
13 | public class TestTakerRepository : BaseRepository, ITestTakerRepository
14 | {
15 | public TestTakerRepository(PlacementTestContext context) : base(context)
16 | {
17 | }
18 |
19 | public Task GetByID(string BannerID, CancellationToken cancellationToken)
20 | {
21 | return Context.TestTakers.FirstOrDefaultAsync(x => x.BannerID == BannerID, cancellationToken);
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/PlacementTest.Persistence/Repository/UnitOfWork.cs:
--------------------------------------------------------------------------------
1 | using PlacementTest.Application.Repository;
2 | using PlacementTest.Persistence.Context;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 |
9 | namespace PlacementTest.Persistence.Repository
10 | {
11 | public class UnitOfWork : IUnitOfWork
12 | {
13 | private readonly PlacementTestContext _context;
14 |
15 | public UnitOfWork(PlacementTestContext context)
16 | {
17 | _context = context;
18 | }
19 | public Task Save(CancellationToken cancellationToken)
20 | {
21 | return _context.SaveChangesAsync(cancellationToken);
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/PlacementTest.Persistence/ServiceExtensions.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore;
2 | using Microsoft.Extensions.Configuration;
3 | using Microsoft.Extensions.DependencyInjection;
4 | using PlacementTest.Application.Repository;
5 | using PlacementTest.Application.Repository.TestTakersRepository;
6 | using PlacementTest.Persistence.Context;
7 | using PlacementTest.Persistence.Repository;
8 | using PlacementTest.Persistence.Repository.TestTakersRepository;
9 |
10 | namespace PlacementTest.Persistence
11 | {
12 | public static class ServiceExtensions
13 | {
14 | public static void ConfigurePersistence(this IServiceCollection services, IConfiguration configuration)
15 | {
16 | var connection = configuration.GetConnectionString("PlacementTestContext");
17 | services.AddDbContext(options => options.UseSqlServer(connection));
18 | services.AddScoped();
19 | services.AddScoped();
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/PlacementTest.WebAPI/Controllers/Base/BaseController.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Mvc;
2 |
3 | namespace PlacementTest.WebAPI.Controllers.Base
4 | {
5 | [Route("api/[controller]/[Action]")]
6 | //[Authorize]
7 | [ApiController]
8 | public abstract class BaseController : ControllerBase
9 | {
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/PlacementTest.WebAPI/Controllers/TestTakerController.cs:
--------------------------------------------------------------------------------
1 | using MediatR;
2 | using Microsoft.AspNetCore.Mvc;
3 | using PlacementTest.Application.Features.TestTakersFeatures;
4 | using PlacementTest.Application.Features.TestTakersFeatures.Get;
5 | using PlacementTest.WebAPI.Controllers.Base;
6 |
7 | namespace PlacementTest.WebAPI.Controllers
8 | {
9 |
10 | public class TestTakerController : BaseController
11 | {
12 | private readonly IMediator _mediator;
13 |
14 | public TestTakerController(IMediator mediator)
15 | {
16 | _mediator = mediator;
17 | }
18 |
19 | [HttpGet]
20 | public async Task>> GetAll(CancellationToken cancellationToken)
21 | {
22 | var response = await _mediator.Send(new GetAllTestTakersRequest(), cancellationToken);
23 | return Ok(response);
24 | }
25 |
26 | [HttpPost]
27 | public async Task> Create(AddTestTakerRequest request,
28 | CancellationToken cancellationToken)
29 | {
30 | var response = await _mediator.Send(request, cancellationToken);
31 | return Ok(response);
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/PlacementTest.WebAPI/Extensions/ApiBehaviorExtensions.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Mvc;
2 |
3 | namespace PlacementTest.WebAPI.Extensions
4 | {
5 | public static class ApiBehaviorExtensions
6 | {
7 | public static void ConfigureApiBehavior(this IServiceCollection services)
8 | {
9 | services.Configure(options =>
10 | {
11 | options.SuppressModelStateInvalidFilter = true;
12 | });
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/PlacementTest.WebAPI/Extensions/CorsPolicyExtensions.cs:
--------------------------------------------------------------------------------
1 | namespace PlacementTest.WebAPI.Extensions
2 | {
3 | public static class CorsPolicyExtensions
4 | {
5 | public static void ConfigureCorsPolicy(this IServiceCollection services)
6 | {
7 | services.AddCors(opt =>
8 | {
9 | opt.AddDefaultPolicy(builder => builder
10 | .AllowAnyOrigin()
11 | .AllowAnyMethod()
12 | .AllowAnyHeader());
13 | });
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/PlacementTest.WebAPI/Extensions/ErrorHandlerExtensions.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Diagnostics;
2 | using PlacementTest.Application.Common.Exceptions;
3 | using System.Net;
4 | using System.Text.Json;
5 |
6 | namespace PlacementTest.WebAPI.Extensions
7 | {
8 | public static class ErrorHandlerExtensions
9 | {
10 | public static void UseErrorHandler(this IApplicationBuilder app)
11 | {
12 | app.UseExceptionHandler(appError =>
13 | {
14 | appError.Run(async context =>
15 | {
16 | var contextFeature = context.Features.Get();
17 | if (contextFeature == null) return;
18 |
19 | context.Response.Headers.Add("Access-Control-Allow-Origin", "*");
20 | context.Response.ContentType = "application/json";
21 |
22 | context.Response.StatusCode = contextFeature.Error switch
23 | {
24 | BadRequestException => (int)HttpStatusCode.BadRequest,
25 | OperationCanceledException => (int)HttpStatusCode.ServiceUnavailable,
26 | NoDataFoundException => (int)HttpStatusCode.NotFound,
27 | _ => (int)HttpStatusCode.InternalServerError
28 | };
29 |
30 | var errorResponse = new
31 | {
32 | statusCode = context.Response.StatusCode,
33 | message = contextFeature.Error.GetBaseException().Message
34 | };
35 |
36 | await context.Response.WriteAsync(JsonSerializer.Serialize(errorResponse));
37 | });
38 | });
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/PlacementTest.WebAPI/PlacementTest.WebAPI.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 | enable
6 | enable
7 |
8 |
9 |
10 |
11 |
12 | all
13 | runtime; build; native; contentfiles; analyzers; buildtransitive
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/PlacementTest.WebAPI/Program.cs:
--------------------------------------------------------------------------------
1 | using PlacementTest.Application;
2 | using PlacementTest.WebAPI.Extensions;
3 | using PlacementTest.Persistence.Context;
4 | using PlacementTest.Persistence;
5 |
6 | var builder = WebApplication.CreateBuilder(args);
7 |
8 | builder.Services.ConfigurePersistence(builder.Configuration);
9 | builder.Services.ConfigureApplication();
10 |
11 | builder.Services.ConfigureApiBehavior();
12 | builder.Services.ConfigureCorsPolicy();
13 |
14 | builder.Services.AddControllers();
15 | builder.Services.AddEndpointsApiExplorer();
16 | builder.Services.AddSwaggerGen();
17 |
18 | var app = builder.Build();
19 |
20 | var serviceScope = app.Services.CreateScope();
21 | var dataContext = serviceScope.ServiceProvider.GetService();
22 | dataContext?.Database.EnsureCreated();
23 |
24 | app.UseSwagger();
25 | app.UseSwaggerUI();
26 | app.UseErrorHandler();
27 | app.UseCors();
28 | app.MapControllers();
29 | app.Run();
--------------------------------------------------------------------------------
/PlacementTest.WebAPI/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://json.schemastore.org/launchsettings.json",
3 | "iisSettings": {
4 | "windowsAuthentication": false,
5 | "anonymousAuthentication": true,
6 | "iisExpress": {
7 | "applicationUrl": "http://localhost:3335",
8 | "sslPort": 44373
9 | }
10 | },
11 | "profiles": {
12 | "http": {
13 | "commandName": "Project",
14 | "dotnetRunMessages": true,
15 | "launchBrowser": true,
16 | "launchUrl": "swagger",
17 | "applicationUrl": "http://localhost:5169",
18 | "environmentVariables": {
19 | "ASPNETCORE_ENVIRONMENT": "Development"
20 | }
21 | },
22 | "https": {
23 | "commandName": "Project",
24 | "dotnetRunMessages": true,
25 | "launchBrowser": true,
26 | "launchUrl": "swagger",
27 | "applicationUrl": "https://localhost:7247;http://localhost:5169",
28 | "environmentVariables": {
29 | "ASPNETCORE_ENVIRONMENT": "Development"
30 | }
31 | },
32 | "IIS Express": {
33 | "commandName": "IISExpress",
34 | "launchBrowser": true,
35 | "launchUrl": "swagger",
36 | "environmentVariables": {
37 | "ASPNETCORE_ENVIRONMENT": "Development"
38 | }
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/PlacementTest.WebAPI/appsettings.Development.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft.AspNetCore": "Warning"
6 | }
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/PlacementTest.WebAPI/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Warning"
5 | }
6 | },
7 | "AllowedHosts": "*",
8 | "ConnectionStrings": {
9 | //"PlacementTestContext": "Data Source=SVR-REPORTING-L\\SQL2014;Initial Catalog=MA22;Trusted_Connection=True;MultipleActiveResultSets=True;App=EntityFramework;Integrated Security=true",
10 | "PlacementTestContext": "Server=M2ETC-MOHANED;Database=PT;Trusted_Connection=True;TrustServerCertificate=True;"
11 | },
12 |
13 | "SwaggerConfig": {
14 | "EndPoint": "/swagger/v1/swagger.json",
15 | "Title": "Placement Test API V1",
16 | "Version": "v1"
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/PlacementTest.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.4.33213.308
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PlacementTest.WebAPI", "PlacementTest.WebAPI\PlacementTest.WebAPI.csproj", "{2BB9AC20-26CF-4A7D-892A-A2A541CEA82C}"
7 | EndProject
8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Core", "Core", "{388349DF-7A11-47D7-8412-8C8E79088D34}"
9 | EndProject
10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PlacementTest.Domain", "PlacementTest.Domain\PlacementTest.Domain.csproj", "{3440021F-4F4A-406D-AAE4-E2475A20F106}"
11 | EndProject
12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PlacementTest.Application", "PlacementTest.Application\PlacementTest.Application.csproj", "{D95B59BE-3EA7-4E80-98A8-9715E4F93A99}"
13 | EndProject
14 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Infrastructure", "Infrastructure", "{7A62318F-0DFF-4469-B839-8334F2976C97}"
15 | EndProject
16 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PlacementTest.Persistence", "PlacementTest.Persistence\PlacementTest.Persistence.csproj", "{588AC9DD-C521-4DD6-B407-D2E3D42B0C83}"
17 | EndProject
18 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Presentation", "Presentation", "{8BBC39D6-D1FC-4922-BB8B-4E80FF24A8B9}"
19 | EndProject
20 | Global
21 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
22 | Debug|Any CPU = Debug|Any CPU
23 | Release|Any CPU = Release|Any CPU
24 | EndGlobalSection
25 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
26 | {2BB9AC20-26CF-4A7D-892A-A2A541CEA82C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27 | {2BB9AC20-26CF-4A7D-892A-A2A541CEA82C}.Debug|Any CPU.Build.0 = Debug|Any CPU
28 | {2BB9AC20-26CF-4A7D-892A-A2A541CEA82C}.Release|Any CPU.ActiveCfg = Release|Any CPU
29 | {2BB9AC20-26CF-4A7D-892A-A2A541CEA82C}.Release|Any CPU.Build.0 = Release|Any CPU
30 | {3440021F-4F4A-406D-AAE4-E2475A20F106}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
31 | {3440021F-4F4A-406D-AAE4-E2475A20F106}.Debug|Any CPU.Build.0 = Debug|Any CPU
32 | {3440021F-4F4A-406D-AAE4-E2475A20F106}.Release|Any CPU.ActiveCfg = Release|Any CPU
33 | {3440021F-4F4A-406D-AAE4-E2475A20F106}.Release|Any CPU.Build.0 = Release|Any CPU
34 | {D95B59BE-3EA7-4E80-98A8-9715E4F93A99}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
35 | {D95B59BE-3EA7-4E80-98A8-9715E4F93A99}.Debug|Any CPU.Build.0 = Debug|Any CPU
36 | {D95B59BE-3EA7-4E80-98A8-9715E4F93A99}.Release|Any CPU.ActiveCfg = Release|Any CPU
37 | {D95B59BE-3EA7-4E80-98A8-9715E4F93A99}.Release|Any CPU.Build.0 = Release|Any CPU
38 | {588AC9DD-C521-4DD6-B407-D2E3D42B0C83}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
39 | {588AC9DD-C521-4DD6-B407-D2E3D42B0C83}.Debug|Any CPU.Build.0 = Debug|Any CPU
40 | {588AC9DD-C521-4DD6-B407-D2E3D42B0C83}.Release|Any CPU.ActiveCfg = Release|Any CPU
41 | {588AC9DD-C521-4DD6-B407-D2E3D42B0C83}.Release|Any CPU.Build.0 = Release|Any CPU
42 | EndGlobalSection
43 | GlobalSection(SolutionProperties) = preSolution
44 | HideSolutionNode = FALSE
45 | EndGlobalSection
46 | GlobalSection(NestedProjects) = preSolution
47 | {2BB9AC20-26CF-4A7D-892A-A2A541CEA82C} = {8BBC39D6-D1FC-4922-BB8B-4E80FF24A8B9}
48 | {3440021F-4F4A-406D-AAE4-E2475A20F106} = {388349DF-7A11-47D7-8412-8C8E79088D34}
49 | {D95B59BE-3EA7-4E80-98A8-9715E4F93A99} = {388349DF-7A11-47D7-8412-8C8E79088D34}
50 | {588AC9DD-C521-4DD6-B407-D2E3D42B0C83} = {7A62318F-0DFF-4469-B839-8334F2976C97}
51 | EndGlobalSection
52 | GlobalSection(ExtensibilityGlobals) = postSolution
53 | SolutionGuid = {1BC4E7FF-D84C-4BFD-A57B-1A3ED5FA587D}
54 | EndGlobalSection
55 | EndGlobal
56 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # .NET Core API - Clean Architecture Example
2 |
3 | .NET Core API project employing Clean Architecture principles along with the MediatR pattern for handling requests and commands. This example emphasizes separation of concerns and maintainability by leveraging MediatR for decoupling business logic from controllers, enabling easier testing and extensibility.
4 |
5 |
6 |
--------------------------------------------------------------------------------