├── TaskManagementAPP
├── .dockerignore
├── .gitignore
├── Business
│ ├── Business.csproj
│ ├── Constants
│ │ └── Messages.cs
│ ├── DependencyResolvers
│ │ └── AutofacBusinessModule.cs
│ ├── Handlers
│ │ ├── Comments
│ │ │ ├── Commands
│ │ │ │ ├── CreateCommentCommand.cs
│ │ │ │ ├── RemoveCommentCommand.cs
│ │ │ │ └── UpdateCommentCommand.cs
│ │ │ └── Validations
│ │ │ │ └── CommentValidator.cs
│ │ ├── TaskStatuses
│ │ │ └── Queries
│ │ │ │ └── GetAllTaskStatusesQuery.cs
│ │ ├── Tasks
│ │ │ ├── Commands
│ │ │ │ ├── CreateTaskCommand.cs
│ │ │ │ ├── RemoveTaskCommand.cs
│ │ │ │ └── UpdateTaskCommand.cs
│ │ │ ├── Queries
│ │ │ │ ├── GetTaskDetailByIdQuery.cs
│ │ │ │ └── GetTasksByUserIdQuery.cs
│ │ │ └── Validations
│ │ │ │ └── TaskValidator.cs
│ │ └── Users
│ │ │ ├── Commands
│ │ │ ├── ConfirmEmailCommand.cs
│ │ │ ├── LoginCommand.cs
│ │ │ └── RegisterCommand.cs
│ │ │ ├── Queries
│ │ │ ├── GetAuthenticatedUserQuery.cs
│ │ │ └── GetUserByEmailQuery.cs
│ │ │ └── Validations
│ │ │ ├── LoginValidator.cs
│ │ │ └── RegisterValidator.cs
│ ├── Mappings
│ │ └── Automapper.cs
│ └── Services
│ │ ├── Abstract
│ │ └── ITokenService.cs
│ │ └── Concrete
│ │ └── TokenManager.cs
├── Core
│ ├── Aspects
│ │ └── Autofac
│ │ │ └── Validation
│ │ │ └── ValidationAspect.cs
│ ├── Configurations
│ │ ├── EmailSettings.cs
│ │ └── JWTOptions.cs
│ ├── Core.csproj
│ ├── CrossCuttingConcerns
│ │ ├── Logging
│ │ │ ├── ErrorLog.cs
│ │ │ ├── LogDetail.cs
│ │ │ └── SeriLog
│ │ │ │ ├── ConfigurationModels
│ │ │ │ └── PostgreSqlConfiguration.cs
│ │ │ │ ├── LoggerServiceBase.cs
│ │ │ │ └── Loggers
│ │ │ │ └── PostgreSqlLogger.cs
│ │ └── Validation
│ │ │ └── FluentValidation
│ │ │ └── ValidationTool.cs
│ ├── DataAccess
│ │ ├── EntityFramework
│ │ │ └── EfEntityRepositoryBase.cs
│ │ ├── IEntityRepository.cs
│ │ └── UnitOfWork.cs
│ ├── DependencyResolvers
│ │ └── CoreModule.cs
│ ├── Entities
│ │ ├── IDTO.cs
│ │ └── IEntity.cs
│ ├── Exceptions
│ │ └── ApiException.cs
│ └── Utilities
│ │ ├── EmailManager.cs
│ │ ├── Extensions
│ │ ├── ExceptionMiddleware.cs
│ │ ├── ExceptionMiddlewareExtensions.cs
│ │ └── ServiceCollectionExtensions.cs
│ │ ├── FileManager.cs
│ │ ├── Helpers
│ │ ├── SecurityKeyHelper.cs
│ │ └── SigningCredentialsHelper.cs
│ │ ├── IEmailService.cs
│ │ ├── Interceptors
│ │ ├── AspectInterceptorSelector.cs
│ │ ├── MethodInterception.cs
│ │ └── MethodInterceptionBaseAttribute.cs
│ │ ├── IoC
│ │ ├── ICoreModule.cs
│ │ └── ServiceTool.cs
│ │ └── Responses
│ │ ├── Abstract
│ │ ├── IDataResponse.cs
│ │ ├── IErrorResponse.cs
│ │ ├── IPagedDataResponse.cs
│ │ ├── IResponse.cs
│ │ └── ISuccessResponse.cs
│ │ └── Concrete
│ │ ├── DataResponse.cs
│ │ ├── ErrorResponse.cs
│ │ ├── PagedDataResponse.cs
│ │ ├── Response.cs
│ │ └── SuccessResponse.cs
├── DataAccess
│ ├── Abstract
│ │ ├── ICommentRepository.cs
│ │ ├── ITaskRepository.cs
│ │ └── ITaskStatusRepository.cs
│ ├── Concrete
│ │ └── EntityFramework
│ │ │ ├── Contexts
│ │ │ └── TaskContext.cs
│ │ │ ├── EfCommentRepository.cs
│ │ │ ├── EfTaskRepository.cs
│ │ │ ├── EfTaskStatusRepository.cs
│ │ │ └── UnitOfWork
│ │ │ └── UnitOfWork.cs
│ ├── Configurations
│ │ ├── CommentConfiguration.cs
│ │ ├── TaskConfiguration.cs
│ │ ├── TaskStatusConfiguration.cs
│ │ ├── UserConfiguration.cs
│ │ └── UserTaskConfiguration.cs
│ ├── DataAccess.csproj
│ └── Migrations
│ │ ├── 20220501210412_CreateDatabase.Designer.cs
│ │ ├── 20220501210412_CreateDatabase.cs
│ │ └── TaskContextModelSnapshot.cs
├── Entities
│ ├── Concrete
│ │ ├── Comment.cs
│ │ ├── Task.cs
│ │ ├── TaskStatus.cs
│ │ ├── User.cs
│ │ └── UserTask.cs
│ ├── Dtos
│ │ ├── CommentDTO.cs
│ │ ├── TaskDTO.cs
│ │ ├── TaskDetailDTO.cs
│ │ ├── TaskStatusDTO.cs
│ │ ├── TokenDTO.cs
│ │ ├── UserDTO.cs
│ │ └── UserTaskDTO.cs
│ └── Entities.csproj
├── TaskManagementAPP.sln
├── WebAPI
│ ├── Controllers
│ │ ├── AuthController.cs
│ │ ├── CommentsController.cs
│ │ ├── TaskStatusesController.cs
│ │ └── TasksController.cs
│ ├── Dockerfile
│ ├── Program.cs
│ ├── Properties
│ │ └── launchSettings.json
│ ├── WebAPI.csproj
│ ├── appsettings.Development.json
│ └── appsettings.json
├── docker-compose.dcproj
└── docker-compose.yml
├── TaskManagementUI
├── .editorconfig
├── .eslintignore
├── .eslintrc.js
├── .gitignore
├── .prettierrc
├── .vscode
│ ├── extensions.json
│ └── settings.json
├── README.md
├── index.html
├── package-lock.json
├── package.json
├── postcss.config.js
├── public
│ ├── favicon.ico
│ └── icons
│ │ ├── favicon-128x128.png
│ │ ├── favicon-16x16.png
│ │ ├── favicon-32x32.png
│ │ └── favicon-96x96.png
├── quasar.config.js
├── src
│ ├── App.vue
│ ├── assets
│ │ └── quasar-logo-vertical.svg
│ ├── boot
│ │ ├── .gitkeep
│ │ └── axios.ts
│ ├── components
│ │ ├── Alert.vue
│ │ ├── CreateTask.vue
│ │ ├── Task.vue
│ │ └── TaskDetail.vue
│ ├── composables
│ │ └── useNotify.ts
│ ├── css
│ │ ├── app.scss
│ │ └── quasar.variables.scss
│ ├── env.d.ts
│ ├── layouts
│ │ └── MainLayout.vue
│ ├── models
│ │ ├── Auth
│ │ │ ├── ConfirmEmail.ts
│ │ │ ├── Login.ts
│ │ │ ├── Register.ts
│ │ │ └── TokenDTO.ts
│ │ ├── Comment
│ │ │ ├── CommentDTO.ts
│ │ │ ├── CreateComment.ts
│ │ │ └── UpdateComment.ts
│ │ ├── Responses
│ │ │ ├── DataResponse.ts
│ │ │ ├── ErrorResponse.ts
│ │ │ └── SuccessResponse.ts
│ │ ├── Task
│ │ │ ├── CreateTask.ts
│ │ │ ├── TaskDTO.ts
│ │ │ ├── TaskDetailDTO.ts
│ │ │ ├── UpdateTask.ts
│ │ │ └── UserTaskDTO.ts
│ │ ├── TaskStatus
│ │ │ └── TaskStatusDTO.ts
│ │ └── UserDTO.ts
│ ├── pages
│ │ ├── Auth.vue
│ │ ├── ConfirmEmail.vue
│ │ ├── ErrorNotFound.vue
│ │ └── IndexPage.vue
│ ├── quasar.d.ts
│ ├── router
│ │ ├── index.ts
│ │ └── routes.ts
│ ├── shims-vue.d.ts
│ ├── stores
│ │ ├── Alert.ts
│ │ ├── Auth.ts
│ │ ├── Comment.ts
│ │ ├── Task.ts
│ │ ├── TaskStatus.ts
│ │ ├── index.ts
│ │ └── store-flag.d.ts
│ └── utilities
│ │ └── validators.ts
├── tailwind.config.js
└── tsconfig.json
├── assets
└── taskmanagement.gif
└── readme.md
/TaskManagementAPP/.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
--------------------------------------------------------------------------------
/TaskManagementAPP/.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/main/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 | [Ll]og/
33 | [Ll]ogs/
34 |
35 | # Visual Studio 2015/2017 cache/options directory
36 | .vs/
37 | # Uncomment if you have tasks that create the project's static files in wwwroot
38 | #wwwroot/
39 |
40 | # Visual Studio 2017 auto generated files
41 | Generated\ Files/
42 |
43 | # MSTest test Results
44 | [Tt]est[Rr]esult*/
45 | [Bb]uild[Ll]og.*
46 |
47 | # NUnit
48 | *.VisualState.xml
49 | TestResult.xml
50 | nunit-*.xml
51 |
52 | # Build Results of an ATL Project
53 | [Dd]ebugPS/
54 | [Rr]eleasePS/
55 | dlldata.c
56 |
57 | # Benchmark Results
58 | BenchmarkDotNet.Artifacts/
59 |
60 | # .NET Core
61 | project.lock.json
62 | project.fragment.lock.json
63 | artifacts/
64 |
65 | # ASP.NET Scaffolding
66 | ScaffoldingReadMe.txt
67 |
68 | # StyleCop
69 | StyleCopReport.xml
70 |
71 | # Files built by Visual Studio
72 | *_i.c
73 | *_p.c
74 | *_h.h
75 | *.ilk
76 | *.meta
77 | *.obj
78 | *.iobj
79 | *.pch
80 | *.pdb
81 | *.ipdb
82 | *.pgc
83 | *.pgd
84 | *.rsp
85 | *.sbr
86 | *.tlb
87 | *.tli
88 | *.tlh
89 | *.tmp
90 | *.tmp_proj
91 | *_wpftmp.csproj
92 | *.log
93 | *.tlog
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 6 auto-generated project file (contains which files were open etc.)
298 | *.vbp
299 |
300 | # Visual Studio 6 workspace and project file (working project files containing files to include in project)
301 | *.dsw
302 | *.dsp
303 |
304 | # Visual Studio 6 technical files
305 | *.ncb
306 | *.aps
307 |
308 | # Visual Studio LightSwitch build output
309 | **/*.HTMLClient/GeneratedArtifacts
310 | **/*.DesktopClient/GeneratedArtifacts
311 | **/*.DesktopClient/ModelManifest.xml
312 | **/*.Server/GeneratedArtifacts
313 | **/*.Server/ModelManifest.xml
314 | _Pvt_Extensions
315 |
316 | # Paket dependency manager
317 | .paket/paket.exe
318 | paket-files/
319 |
320 | # FAKE - F# Make
321 | .fake/
322 |
323 | # CodeRush personal settings
324 | .cr/personal
325 |
326 | # Python Tools for Visual Studio (PTVS)
327 | __pycache__/
328 | *.pyc
329 |
330 | # Cake - Uncomment if you are using it
331 | # tools/**
332 | # !tools/packages.config
333 |
334 | # Tabs Studio
335 | *.tss
336 |
337 | # Telerik's JustMock configuration file
338 | *.jmconfig
339 |
340 | # BizTalk build output
341 | *.btp.cs
342 | *.btm.cs
343 | *.odx.cs
344 | *.xsd.cs
345 |
346 | # OpenCover UI analysis results
347 | OpenCover/
348 |
349 | # Azure Stream Analytics local run output
350 | ASALocalRun/
351 |
352 | # MSBuild Binary and Structured Log
353 | *.binlog
354 |
355 | # NVidia Nsight GPU debugger configuration file
356 | *.nvuser
357 |
358 | # MFractors (Xamarin productivity tool) working folder
359 | .mfractor/
360 |
361 | # Local History for Visual Studio
362 | .localhistory/
363 |
364 | # Visual Studio History (VSHistory) files
365 | .vshistory/
366 |
367 | # BeatPulse healthcheck temp database
368 | healthchecksdb
369 |
370 | # Backup folder for Package Reference Convert tool in Visual Studio 2017
371 | MigrationBackup/
372 |
373 | # Ionide (cross platform F# VS Code tools) working folder
374 | .ionide/
375 |
376 | # Fody - auto-generated XML schema
377 | FodyWeavers.xsd
378 |
379 | # VS Code files for those working on multiple tools
380 | .vscode/*
381 | !.vscode/settings.json
382 | !.vscode/tasks.json
383 | !.vscode/launch.json
384 | !.vscode/extensions.json
385 | *.code-workspace
386 |
387 | # Local History for Visual Studio Code
388 | .history/
389 |
390 | # Windows Installer files from build outputs
391 | *.cab
392 | *.msi
393 | *.msix
394 | *.msm
395 | *.msp
396 |
397 | # JetBrains Rider
398 | *.sln.iml
--------------------------------------------------------------------------------
/TaskManagementAPP/Business/Business.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net6.0
5 | enable
6 | disable
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/TaskManagementAPP/Business/Constants/Messages.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 Business.Constants
8 | {
9 | public static class Messages
10 | {
11 |
12 | public static string AddedSuccesfully => "Added Successfully";
13 | public static string UpdatedSuccessfully => "Updated Successfully";
14 | public static string DeletedSuccessfully => "Deleted Successfully";
15 | public static string NotFound => "Entity not found";
16 |
17 | public static string CommentNotYours => "The comment is not yours";
18 | public static string UserNameOrPasswordIsIncorrect => "Username or password is incorrect";
19 | public static string ConfirmYourAccount => "Please confirm your account";
20 | public static string EmailIsAlreadyExist => "Email is already exist";
21 | public static string UsernameIsAlreadyExist => "Username is already exist";
22 | public static string PasswordDontMatchWithConfirmation => "Password doesn't match its confirmation";
23 | public static string RegisterSuccessfully => "Register successfuly please look at your mail box for account confirmation.";
24 | public static string UserNotFound => "User not found";
25 | public static string TokenOrUserNotFound => "Token or User Not Found";
26 | public static string RefreshTokenNotFound => "Refresh Token Not Found";
27 | public static string AlreadyAccountConfirmed => "Already your account confirmed";
28 | public static string SuccessfullyAccountConfirmed => "Account confirmed successfully.You can login now";
29 | public static string AccountDontConfirmed => "Account dont Confirmed";
30 | public static string LogoutSuccessfully => "Logout successfully";
31 | public static string RefreshTokenExpired => "Refresh Token Expired";
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/TaskManagementAPP/Business/DependencyResolvers/AutofacBusinessModule.cs:
--------------------------------------------------------------------------------
1 | using Autofac;
2 | using Autofac.Extras.DynamicProxy;
3 | using AutoMapper;
4 | using Business.Services.Abstract;
5 | using Business.Services.Concrete;
6 | using Castle.DynamicProxy;
7 | using Core.DataAccess;
8 | using Core.Utilities.Interceptors;
9 | using DataAccess.Abstract;
10 | using DataAccess.Concrete.EntityFramework;
11 | using DataAccess.Concrete.EntityFramework.UnitOfWork;
12 | using MediatR;
13 |
14 | namespace Business.DependencyResolvers
15 | {
16 | public class AutofacBusinessModule : Module
17 | {
18 | protected override void Load(ContainerBuilder builder)
19 | {
20 | builder.RegisterType().As().InstancePerLifetimeScope();
21 | builder.RegisterType().As().InstancePerLifetimeScope();
22 | builder.RegisterType().As().InstancePerLifetimeScope();
23 | builder.RegisterType().As().InstancePerLifetimeScope();
24 | builder.RegisterType().As().InstancePerLifetimeScope();
25 |
26 | var assembly = System.Reflection.Assembly.GetExecutingAssembly();
27 |
28 | builder.RegisterAssemblyTypes(assembly)
29 | .Where(t => typeof(Profile).IsAssignableFrom(t) && !t.IsAbstract && t.IsPublic)
30 | .As();
31 |
32 | builder.Register(c => new MapperConfiguration(cfg =>
33 | {
34 | foreach (var profile in c.Resolve>())
35 | {
36 | cfg.AddProfile(profile);
37 | }
38 | })).AsSelf().SingleInstance();
39 |
40 | builder.Register(c => c.Resolve()
41 | .CreateMapper(c.Resolve))
42 | .As()
43 | .InstancePerLifetimeScope();
44 |
45 | builder.RegisterAssemblyTypes(assembly).AsImplementedInterfaces()
46 | .EnableInterfaceInterceptors(new ProxyGenerationOptions()
47 | {
48 | Selector = new AspectInterceptorSelector()
49 | }).SingleInstance().InstancePerDependency();
50 | }
51 | }
52 | }
53 |
54 |
--------------------------------------------------------------------------------
/TaskManagementAPP/Business/Handlers/Comments/Commands/CreateCommentCommand.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using Business.Constants;
3 | using Business.Handlers.Comments.Validations;
4 | using Core.Aspects.Autofac.Validation;
5 | using Core.DataAccess;
6 | using Core.Utilities.Responses.Abstract;
7 | using Core.Utilities.Responses.Concrete;
8 | using DataAccess.Abstract;
9 | using Entities.Concrete;
10 | using MediatR;
11 | using Microsoft.AspNetCore.Http;
12 | using System;
13 | using System.Collections.Generic;
14 | using System.Linq;
15 | using System.Security.Claims;
16 | using System.Text;
17 | using System.Threading.Tasks;
18 |
19 | namespace Business.Handlers.Comments.Commands
20 | {
21 | public class CreateCommentCommand:IRequest
22 | {
23 | public int TaskId { get; set; }
24 | public string Description { get; set; }
25 |
26 | public class CreateCommentCommandHandler : IRequestHandler
27 | {
28 | private ICommentRepository _commentRepository;
29 | private IMapper _mapper;
30 | private IHttpContextAccessor _httpContextAccessor;
31 | private IUnitOfWork _unitOfWork;
32 |
33 | public CreateCommentCommandHandler(ICommentRepository commentRepository, IMapper mapper, IHttpContextAccessor httpContextAccessor, IUnitOfWork unitOfWork)
34 | {
35 | _commentRepository = commentRepository;
36 | _mapper = mapper;
37 | _httpContextAccessor = httpContextAccessor;
38 | _unitOfWork = unitOfWork;
39 | }
40 |
41 |
42 | [ValidationAspect(typeof(CreateCommentValidator))]
43 | public async Task Handle(CreateCommentCommand request, CancellationToken cancellationToken)
44 | {
45 | var userid = _httpContextAccessor?.HttpContext?.User?.Claims?.FirstOrDefault(x => x.Type == ClaimTypes.NameIdentifier)?.Value;
46 | var comment = _mapper.Map(request);
47 | comment.CommentDate = DateTime.UtcNow;
48 | comment.UserId = userid;
49 | await _commentRepository.AddAsync(comment);
50 | await _unitOfWork.SaveChangesAsync();
51 | return new SuccessResponse(200, Messages.AddedSuccesfully);
52 | }
53 | }
54 |
55 |
56 |
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/TaskManagementAPP/Business/Handlers/Comments/Commands/RemoveCommentCommand.cs:
--------------------------------------------------------------------------------
1 | using Business.Constants;
2 | using Core.DataAccess;
3 | using Core.Exceptions;
4 | using Core.Utilities.Responses.Abstract;
5 | using Core.Utilities.Responses.Concrete;
6 | using DataAccess.Abstract;
7 | using MediatR;
8 | using Microsoft.AspNetCore.Http;
9 | using System;
10 | using System.Collections.Generic;
11 | using System.Linq;
12 | using System.Security.Claims;
13 | using System.Text;
14 | using System.Threading.Tasks;
15 |
16 | namespace Business.Handlers.Comments.Commands
17 | {
18 | public class RemoveCommentCommand:IRequest
19 | {
20 | public int Id { get; set; }
21 | public RemoveCommentCommand(int id)
22 | {
23 | Id = id;
24 | }
25 |
26 | public class RemoveCommentCommandHandler : IRequestHandler
27 | {
28 | private ICommentRepository _commentRepository;
29 | private IUnitOfWork _unitOfWork;
30 | private IHttpContextAccessor _httpContextAccessor;
31 |
32 | public RemoveCommentCommandHandler(ICommentRepository commentRepository, IUnitOfWork unitOfWork, IHttpContextAccessor httpContextAccessor)
33 | {
34 | _commentRepository = commentRepository;
35 | _unitOfWork = unitOfWork;
36 | _httpContextAccessor = httpContextAccessor;
37 | }
38 |
39 | public async Task Handle(RemoveCommentCommand request, CancellationToken cancellationToken)
40 | {
41 | var userid = _httpContextAccessor?.HttpContext?.User?.Claims?.FirstOrDefault(x => x.Type == ClaimTypes.NameIdentifier)?.Value;
42 | var existcomment = await _commentRepository.GetByIdAsync(request.Id);
43 | if (existcomment == null)
44 | {
45 | throw new ApiException(404, Messages.NotFound);
46 | }
47 | if (existcomment.UserId != userid)
48 | {
49 | throw new ApiException(401, Messages.CommentNotYours);
50 | }
51 | _commentRepository.Remove(existcomment);
52 | await _unitOfWork.SaveChangesAsync();
53 | return new SuccessResponse(200, Messages.DeletedSuccessfully);
54 | }
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/TaskManagementAPP/Business/Handlers/Comments/Commands/UpdateCommentCommand.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using Business.Constants;
3 | using Business.Handlers.Comments.Validations;
4 | using Core.Aspects.Autofac.Validation;
5 | using Core.DataAccess;
6 | using Core.Exceptions;
7 | using Core.Utilities.Responses.Abstract;
8 | using Core.Utilities.Responses.Concrete;
9 | using DataAccess.Abstract;
10 | using MediatR;
11 | using Microsoft.AspNetCore.Http;
12 | using System;
13 | using System.Collections.Generic;
14 | using System.Linq;
15 | using System.Security.Claims;
16 | using System.Text;
17 | using System.Threading.Tasks;
18 |
19 | namespace Business.Handlers.Comments.Commands
20 | {
21 | public class UpdateCommentCommand:IRequest
22 | {
23 | public int Id { get; set; }
24 | public string Description { get; set; }
25 |
26 | public class UpdateCommentCommandHandler : IRequestHandler
27 | {
28 | private ICommentRepository _commentRepository;
29 | private IMapper _mapper;
30 | private IHttpContextAccessor _httpContextAccessor;
31 | private IUnitOfWork _unitOfWork;
32 |
33 | public UpdateCommentCommandHandler(ICommentRepository commentRepository, IMapper mapper, IHttpContextAccessor httpContextAccessor, IUnitOfWork unitOfWork)
34 | {
35 | _commentRepository = commentRepository;
36 | _mapper = mapper;
37 | _httpContextAccessor = httpContextAccessor;
38 | _unitOfWork = unitOfWork;
39 | }
40 |
41 | [ValidationAspect(typeof(UpdateCommentValidator))]
42 | public async Task Handle(UpdateCommentCommand request, CancellationToken cancellationToken)
43 | {
44 | var userid = _httpContextAccessor?.HttpContext?.User?.Claims?.FirstOrDefault(x => x.Type == ClaimTypes.NameIdentifier)?.Value;
45 | var existcomment = await _commentRepository.GetByIdAsync(request.Id);
46 | if (existcomment == null)
47 | {
48 | throw new ApiException(404, Messages.NotFound);
49 | }
50 | if (existcomment.UserId != userid)
51 | {
52 | throw new ApiException(401, Messages.CommentNotYours);
53 | }
54 | var updatedcomment = _mapper.Map(request, existcomment);
55 | _commentRepository.Update(updatedcomment);
56 | await _unitOfWork.SaveChangesAsync();
57 | return new SuccessResponse(200,Messages.UpdatedSuccessfully);
58 | }
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/TaskManagementAPP/Business/Handlers/Comments/Validations/CommentValidator.cs:
--------------------------------------------------------------------------------
1 | using Business.Handlers.Comments.Commands;
2 | using FluentValidation;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 |
9 | namespace Business.Handlers.Comments.Validations
10 | {
11 | public class CreateCommentValidator: AbstractValidator
12 | {
13 | public CreateCommentValidator()
14 | {
15 | RuleFor(x => x.Description).NotEmpty().WithMessage("Description").MinimumLength(5);
16 | RuleFor(x => x.TaskId).NotEmpty().WithMessage("TaskId is required");
17 | }
18 | }
19 |
20 | public class UpdateCommentValidator : AbstractValidator
21 | {
22 | public UpdateCommentValidator()
23 | {
24 | RuleFor(x => x.Id).NotEmpty().WithMessage("Id is required");
25 | RuleFor(x => x.Description).NotEmpty().WithMessage("Description").MinimumLength(5);
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/TaskManagementAPP/Business/Handlers/TaskStatuses/Queries/GetAllTaskStatusesQuery.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using Core.Utilities.Responses.Abstract;
3 | using Core.Utilities.Responses.Concrete;
4 | using DataAccess.Abstract;
5 | using Entities.Dtos;
6 | using MediatR;
7 | using System;
8 | using System.Collections.Generic;
9 | using System.Linq;
10 | using System.Text;
11 | using System.Threading.Tasks;
12 |
13 | namespace Business.Handlers.TaskStatuses.Queries
14 | {
15 | public class GetAllTaskStatusesQuery : IRequest
16 | {
17 | public class GetAllTaskStatusesQueryHandler : IRequestHandler
18 | {
19 | private ITaskStatusRepository _taskStatusRepository;
20 | private IMapper _mapper;
21 |
22 | public GetAllTaskStatusesQueryHandler(ITaskStatusRepository taskStatusRepository, IMapper mapper)
23 | {
24 | _taskStatusRepository = taskStatusRepository;
25 | _mapper = mapper;
26 | }
27 |
28 | public async Task Handle(GetAllTaskStatusesQuery request, CancellationToken cancellationToken)
29 | {
30 | var taskStatuses = await _taskStatusRepository.GetAllAsync();
31 | var mappedtaskStatuses = _mapper.Map>(taskStatuses);
32 | return new DataResponse>(mappedtaskStatuses,200);
33 | }
34 | }
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/TaskManagementAPP/Business/Handlers/Tasks/Commands/CreateTaskCommand.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using Business.Constants;
3 | using Business.Handlers.Tasks.Validations;
4 | using Core.Aspects.Autofac.Validation;
5 | using Core.DataAccess;
6 | using Core.Utilities.Responses.Abstract;
7 | using Core.Utilities.Responses.Concrete;
8 | using DataAccess.Abstract;
9 | using Entities.Concrete;
10 | using MediatR;
11 | using Microsoft.AspNetCore.Http;
12 | using System;
13 | using System.Collections.Generic;
14 | using System.Linq;
15 | using System.Security.Claims;
16 | using System.Text;
17 | using System.Threading.Tasks;
18 | using Task = Entities.Concrete.Task;
19 |
20 | namespace Business.Handlers.Tasks.Commands
21 | {
22 | public class CreateTaskCommand : IRequest
23 | {
24 | public string Title { get; set; }
25 | public string Description { get; set; }
26 | public string StringDeadline { get; set; }
27 | public string[] UserIds { get; set; }
28 |
29 | public class CreateTaskCommandHandler : IRequestHandler
30 | {
31 | private ITaskRepository _taskRepository;
32 | private IUnitOfWork _unitOfWork;
33 | private IHttpContextAccessor _httpContextAccessor;
34 | private IMapper _mapper;
35 |
36 | public CreateTaskCommandHandler(ITaskRepository taskRepository, IUnitOfWork unitOfWork, IHttpContextAccessor httpContextAccessor, IMapper mapper)
37 | {
38 | _taskRepository = taskRepository;
39 | _unitOfWork = unitOfWork;
40 | _httpContextAccessor = httpContextAccessor;
41 | _mapper = mapper;
42 | }
43 |
44 | [ValidationAspect(typeof(CreateTaskValidator))]
45 | public async Task Handle(CreateTaskCommand request, CancellationToken cancellationToken)
46 | {
47 | var userid = _httpContextAccessor?.HttpContext?.User?.Claims?.FirstOrDefault(x => x.Type == ClaimTypes.NameIdentifier)?.Value;
48 | var task = _mapper.Map(request);
49 | task.CreatorId = userid;
50 | task.TaskStatusId = 1;
51 | task.Deadline = DateTime.ParseExact(request.StringDeadline, "dd-MM-yyyy HH:mm", null).ToUniversalTime();
52 | task.UserTasks = request.UserIds.Select(x => new UserTask() { UserId = x, TaskId = task.Id }).ToList();
53 | await _taskRepository.AddAsync(task);
54 | await _unitOfWork.SaveChangesAsync();
55 | return new SuccessResponse(200, Messages.AddedSuccesfully);
56 | }
57 | }
58 | }
59 |
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/TaskManagementAPP/Business/Handlers/Tasks/Commands/RemoveTaskCommand.cs:
--------------------------------------------------------------------------------
1 | using Business.Constants;
2 | using Core.DataAccess;
3 | using Core.Exceptions;
4 | using Core.Utilities.Responses.Abstract;
5 | using Core.Utilities.Responses.Concrete;
6 | using DataAccess.Abstract;
7 | using MediatR;
8 | using System;
9 | using System.Collections.Generic;
10 | using System.Linq;
11 | using System.Text;
12 | using System.Threading.Tasks;
13 |
14 | namespace Business.Handlers.Tasks.Commands
15 | {
16 | public class RemoveTaskCommand : IRequest
17 | {
18 | public int Id { get; set; }
19 | public RemoveTaskCommand(int id)
20 | {
21 | Id = id;
22 | }
23 | public class RemoveTaskCommandHandler : IRequestHandler
24 | {
25 | private IUnitOfWork _unitOfWork;
26 | private ITaskRepository _taskRepository;
27 |
28 | public RemoveTaskCommandHandler(IUnitOfWork unitOfWork, ITaskRepository taskRepository)
29 | {
30 | _unitOfWork = unitOfWork;
31 | _taskRepository = taskRepository;
32 | }
33 |
34 | public async Task Handle(RemoveTaskCommand request, CancellationToken cancellationToken)
35 | {
36 | var task = await _taskRepository.GetByIdAsync(request.Id);
37 | if (task == null)
38 | {
39 | throw new ApiException(404, Messages.NotFound);
40 | }
41 | _taskRepository.Remove(task);
42 | await _unitOfWork.SaveChangesAsync();
43 | return new SuccessResponse(200, Messages.DeletedSuccessfully);
44 | }
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/TaskManagementAPP/Business/Handlers/Tasks/Commands/UpdateTaskCommand.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using Business.Constants;
3 | using Business.Handlers.Tasks.Validations;
4 | using Core.Aspects.Autofac.Validation;
5 | using Core.DataAccess;
6 | using Core.Exceptions;
7 | using Core.Utilities.Responses.Abstract;
8 | using Core.Utilities.Responses.Concrete;
9 | using DataAccess.Abstract;
10 | using Entities.Concrete;
11 | using MediatR;
12 | using System.Globalization;
13 |
14 | namespace Business.Handlers.Tasks.Commands
15 | {
16 | public class UpdateTaskCommand:IRequest
17 | {
18 | public int Id { get; set; }
19 | public string Title { get; set; }
20 | public string Description { get; set; }
21 | public string StringDeadline { get; set; }
22 | public int TaskStatusId { get; set; }
23 | public string[] UserIds { get; set; }
24 |
25 |
26 | public class UpdateTaskCommandHandler : IRequestHandler
27 | {
28 | private ITaskRepository _taskRepository;
29 | private IUnitOfWork _unitOfWork;
30 | private IMapper _mapper;
31 |
32 | public UpdateTaskCommandHandler(ITaskRepository taskRepository, IUnitOfWork unitOfWork, IMapper mapper)
33 | {
34 | _taskRepository = taskRepository;
35 | _unitOfWork = unitOfWork;
36 | _mapper = mapper;
37 | }
38 |
39 |
40 | [ValidationAspect(typeof(UpdateTaskValidator))]
41 | public async Task Handle(UpdateTaskCommand request, CancellationToken cancellationToken)
42 | {
43 | var task = await _taskRepository.GetTaskWithUserTasksByIdAsync(request.Id);
44 | if (task == null)
45 | {
46 | throw new ApiException(404, Messages.NotFound);
47 | }
48 | var mappedtask = _mapper.Map(request, task);
49 | mappedtask.UserTasks = request.UserIds.Select(userid => new UserTask()
50 | {
51 | TaskId = task.Id,
52 | UserId = userid
53 | }).ToList();
54 | mappedtask.Deadline = DateTime.ParseExact(request.StringDeadline, "dd-MM-yyyy HH:mm",null).ToUniversalTime();
55 | _taskRepository.Update(mappedtask);
56 | await _unitOfWork.SaveChangesAsync();
57 | return new SuccessResponse(200, Messages.UpdatedSuccessfully);
58 | }
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/TaskManagementAPP/Business/Handlers/Tasks/Queries/GetTaskDetailByIdQuery.cs:
--------------------------------------------------------------------------------
1 | using Business.Constants;
2 | using Core.Exceptions;
3 | using Core.Utilities.Responses.Abstract;
4 | using Core.Utilities.Responses.Concrete;
5 | using DataAccess.Abstract;
6 | using Entities.Dtos;
7 | using MediatR;
8 | using System;
9 | using System.Collections.Generic;
10 | using System.Linq;
11 | using System.Text;
12 | using System.Threading.Tasks;
13 |
14 | namespace Business.Handlers.Tasks.Queries
15 | {
16 | public class GetTaskDetailByIdQuery:IRequest
17 | {
18 | public int Id { get; set; }
19 |
20 | public GetTaskDetailByIdQuery(int id)
21 | {
22 | Id = id;
23 | }
24 | public class GetTaskDetailByIdQueryHandler : IRequestHandler
25 | {
26 | private ITaskRepository _taskRepository;
27 | public GetTaskDetailByIdQueryHandler(ITaskRepository taskRepository)
28 | {
29 | _taskRepository = taskRepository;
30 | }
31 |
32 | public async Task Handle(GetTaskDetailByIdQuery request, CancellationToken cancellationToken)
33 | {
34 | var taskdetail = await _taskRepository.GetTaskDetailByIdAsync(request.Id);
35 | if (taskdetail == null)
36 | {
37 | throw new ApiException(404, Messages.NotFound);
38 | }
39 | return new DataResponse(taskdetail, 200);
40 | }
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/TaskManagementAPP/Business/Handlers/Tasks/Queries/GetTasksByUserIdQuery.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using Core.Utilities.Responses.Abstract;
3 | using Core.Utilities.Responses.Concrete;
4 | using DataAccess.Abstract;
5 | using Entities.Dtos;
6 | using MediatR;
7 | using Microsoft.AspNetCore.Http;
8 |
9 | namespace Business.Handlers.Tasks.Queries
10 | {
11 | public class GetTasksByUserIdQuery:IRequest
12 | {
13 | public string UserId { get; set; }
14 | public GetTasksByUserIdQuery(string userid)
15 | {
16 | UserId = userid;
17 | }
18 | public class GetTasksByUserIdQueryHandler : IRequestHandler
19 | {
20 | private ITaskRepository _taskRepository;
21 | private IHttpContextAccessor _httpContextAccessor;
22 | private IMapper _mapper;
23 |
24 | public GetTasksByUserIdQueryHandler(ITaskRepository taskRepository, IHttpContextAccessor httpContextAccessor, IMapper mapper)
25 | {
26 | _taskRepository = taskRepository;
27 | _httpContextAccessor = httpContextAccessor;
28 | _mapper = mapper;
29 | }
30 |
31 | public async Task Handle(GetTasksByUserIdQuery request, CancellationToken cancellationToken)
32 | {
33 | var tasks = await _taskRepository.GetTasksByUserIdAsync(request.UserId);
34 | return new DataResponse>(tasks, 200);
35 | }
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/TaskManagementAPP/Business/Handlers/Tasks/Validations/TaskValidator.cs:
--------------------------------------------------------------------------------
1 | using Business.Handlers.Tasks.Commands;
2 | using FluentValidation;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 |
9 | namespace Business.Handlers.Tasks.Validations
10 | {
11 | public class CreateTaskValidator: AbstractValidator
12 | {
13 | public CreateTaskValidator()
14 | {
15 | RuleFor(x => x.Title).NotEmpty().WithMessage("Title is required").MinimumLength(5); ;
16 | RuleFor(x => x.Description).NotEmpty().WithMessage("Description is required").MinimumLength(5);
17 | RuleFor(x => x.StringDeadline).NotEmpty().WithMessage("Deadline is required");
18 | RuleFor(x => x.UserIds).NotEmpty().WithMessage("At least one user is required");
19 | }
20 | }
21 |
22 | public class UpdateTaskValidator : AbstractValidator
23 | {
24 | public UpdateTaskValidator()
25 | {
26 | RuleFor(x => x.Title).NotEmpty().WithMessage("Title is required").MinimumLength(5);
27 | RuleFor(x => x.Description).NotEmpty().WithMessage("Description is required").MinimumLength(5);
28 | RuleFor(x => x.StringDeadline).NotEmpty().WithMessage("Deadline is required");
29 | RuleFor(x => x.TaskStatusId).NotEmpty().WithMessage("Task Status is required");
30 | RuleFor(x => x.UserIds).NotEmpty().WithMessage("At least one user is required");
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/TaskManagementAPP/Business/Handlers/Users/Commands/ConfirmEmailCommand.cs:
--------------------------------------------------------------------------------
1 | using Business.Constants;
2 | using Core.Exceptions;
3 | using Core.Utilities.Responses.Abstract;
4 | using Core.Utilities.Responses.Concrete;
5 | using Entities.Concrete;
6 | using MediatR;
7 | using Microsoft.AspNetCore.Identity;
8 | using Microsoft.AspNetCore.WebUtilities;
9 | using System;
10 | using System.Collections.Generic;
11 | using System.Linq;
12 | using System.Text;
13 | using System.Threading.Tasks;
14 |
15 | namespace Business.Handlers.Users.Commands
16 | {
17 | public class ConfirmEmailCommand : IRequest
18 | {
19 | public string UserId { get; set; }
20 | public string Token { get; set; }
21 |
22 |
23 | public class ConfirmEmailCommandHandler : IRequestHandler
24 | {
25 | private UserManager _userManager;
26 |
27 | public ConfirmEmailCommandHandler(UserManager userManager)
28 | {
29 | _userManager = userManager;
30 | }
31 |
32 | public async Task Handle(ConfirmEmailCommand request, CancellationToken cancellationToken)
33 | {
34 | if (request.UserId == null || request.Token == null)
35 | {
36 | throw new ApiException(404, Messages.TokenOrUserNotFound);
37 | }
38 | var user = await _userManager.FindByIdAsync(request.UserId);
39 | if (user == null)
40 | {
41 | throw new ApiException(404, Messages.UserNotFound);
42 | }
43 | if (user.EmailConfirmed)
44 | {
45 | throw new ApiException(400, Messages.AlreadyAccountConfirmed);
46 | }
47 | var tokenDecodedBytes = WebEncoders.Base64UrlDecode(request.Token);
48 | var tokenDecoded = Encoding.UTF8.GetString(tokenDecodedBytes);
49 | var result = await _userManager.ConfirmEmailAsync(user, tokenDecoded);
50 | if (result.Succeeded)
51 | {
52 | return new SuccessResponse(200, Messages.SuccessfullyAccountConfirmed);
53 | }
54 | throw new ApiException(400, Messages.AccountDontConfirmed);
55 | }
56 | }
57 | }
58 |
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/TaskManagementAPP/Business/Handlers/Users/Commands/LoginCommand.cs:
--------------------------------------------------------------------------------
1 | using Business.Constants;
2 | using Business.Handlers.Users.Validations;
3 | using Business.Services.Abstract;
4 | using Core.Aspects.Autofac.Validation;
5 | using Core.DataAccess;
6 | using Core.Exceptions;
7 | using Core.Utilities.Responses.Abstract;
8 | using Core.Utilities.Responses.Concrete;
9 | using DataAccess.Abstract;
10 | using Entities.Concrete;
11 | using Entities.Dtos;
12 | using MediatR;
13 | using Microsoft.AspNetCore.Identity;
14 | using System;
15 | using System.Collections.Generic;
16 | using System.Linq;
17 | using System.Text;
18 | using System.Threading.Tasks;
19 |
20 | namespace Business.Handlers.Users.Commands
21 | {
22 | public class LoginCommand:IRequest
23 | {
24 | public string UserName { get; set; }
25 | public string Password { get; set; }
26 |
27 | public class LoginCommandHandler : IRequestHandler
28 | {
29 | private UserManager _userManager;
30 | private ITokenService _tokenService;
31 |
32 | public LoginCommandHandler(UserManager userManager,ITokenService tokenService)
33 | {
34 | _tokenService = tokenService;
35 | _userManager = userManager;
36 | }
37 |
38 | [ValidationAspect(typeof(LoginValidator))]
39 | public async Task Handle(LoginCommand request, CancellationToken cancellationToken)
40 | {
41 | var user = await _userManager.FindByNameAsync(request.UserName);
42 | if (user == null)
43 | {
44 | throw new ApiException(400, Messages.UserNameOrPasswordIsIncorrect);
45 | }
46 | if (!user.EmailConfirmed)
47 | {
48 | throw new ApiException(400, Messages.ConfirmYourAccount);
49 | }
50 | var identityResult = await _userManager.CheckPasswordAsync(user, request.Password);
51 | if (!identityResult)
52 | {
53 | throw new ApiException(400, Messages.UserNameOrPasswordIsIncorrect);
54 | }
55 | var token = await _tokenService.CreateToken(user);
56 | return new DataResponse(token, 200);
57 | }
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/TaskManagementAPP/Business/Handlers/Users/Commands/RegisterCommand.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using Business.Constants;
3 | using Business.Handlers.Users.Validations;
4 | using Core.Aspects.Autofac.Validation;
5 | using Core.Exceptions;
6 | using Core.Utilities;
7 | using Core.Utilities.Responses.Abstract;
8 | using Core.Utilities.Responses.Concrete;
9 | using Entities.Concrete;
10 | using MediatR;
11 | using Microsoft.AspNetCore.Identity;
12 | using Microsoft.AspNetCore.WebUtilities;
13 | using System;
14 | using System.Collections.Generic;
15 | using System.Linq;
16 | using System.Text;
17 | using System.Threading.Tasks;
18 |
19 | namespace Business.Handlers.Users.Commands
20 | {
21 | public class RegisterCommand:IRequest
22 | {
23 | public string Email { get; set; }
24 | public string FirstName { get; set; }
25 | public string LastName { get; set; }
26 | public string UserName { get; set; }
27 | public string Password { get; set; }
28 | public string ConfirmPassword { get; set; }
29 |
30 |
31 | public class RegisterCommandHandler : IRequestHandler
32 | {
33 | private UserManager _userManager;
34 | private IMapper _mapper;
35 | private IEmailService _emailService;
36 | public RegisterCommandHandler(UserManager userManager, IMapper mapper, IEmailService emailService)
37 | {
38 | _userManager = userManager;
39 | _mapper = mapper;
40 | _emailService = emailService;
41 | }
42 |
43 | [ValidationAspect(typeof(RegisterValidator))]
44 | public async Task Handle(RegisterCommand request, CancellationToken cancellationToken)
45 | {
46 | var email = await _userManager.FindByEmailAsync(request.Email);
47 | if (email != null)
48 | {
49 | throw new ApiException(400, Messages.EmailIsAlreadyExist);
50 | }
51 | var username = await _userManager.FindByNameAsync(request.UserName);
52 | if (username != null)
53 | {
54 | throw new ApiException(400, Messages.UsernameIsAlreadyExist);
55 | }
56 | if (request.Password != request.ConfirmPassword)
57 | {
58 | throw new ApiException(400, Messages.PasswordDontMatchWithConfirmation);
59 | }
60 | var user = _mapper.Map(request);
61 | var IdentityResult = await _userManager.CreateAsync(user, request.Password);
62 | if (IdentityResult.Succeeded)
63 | {
64 | string token = await _userManager.GenerateEmailConfirmationTokenAsync(user);
65 | byte[] tokenGeneratedBytes = Encoding.UTF8.GetBytes(token);
66 | var tokenEncoded = WebEncoders.Base64UrlEncode(tokenGeneratedBytes);
67 | string link = "http://localhost:8080/confirmemail/" + user.Id + "/" + tokenEncoded;
68 | await _emailService.ConfirmationMailAsync(link, request.Email);
69 | return new SuccessResponse(200, Messages.RegisterSuccessfully);
70 | }
71 | else
72 | {
73 | throw new ApiException(400, IdentityResult.Errors.Select(e => e.Description).ToList());
74 | }
75 | }
76 | }
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/TaskManagementAPP/Business/Handlers/Users/Queries/GetAuthenticatedUserQuery.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using Business.Constants;
3 | using Core.Exceptions;
4 | using Core.Utilities.Responses.Abstract;
5 | using Core.Utilities.Responses.Concrete;
6 | using Entities.Concrete;
7 | using Entities.Dtos;
8 | using MediatR;
9 | using Microsoft.AspNetCore.Identity;
10 | using System;
11 | using System.Collections.Generic;
12 | using System.Linq;
13 | using System.Text;
14 | using System.Threading.Tasks;
15 |
16 | namespace Business.Handlers.Users.Queries
17 | {
18 | public class GetAuthenticatedUserQuery:IRequest
19 | {
20 | public string UserId { get; set; }
21 | public GetAuthenticatedUserQuery(string userid)
22 | {
23 | UserId = userid;
24 | }
25 | public class GetAuthenticatedUserQueryHander : IRequestHandler
26 | {
27 | private UserManager _userManager;
28 | private IMapper _mapper;
29 |
30 | public GetAuthenticatedUserQueryHander(UserManager userManager,IMapper mapper)
31 | {
32 | _userManager = userManager;
33 | _mapper = mapper;
34 | }
35 |
36 | public async Task Handle(GetAuthenticatedUserQuery request, CancellationToken cancellationToken)
37 | {
38 | var user = await _userManager.FindByIdAsync(request.UserId);
39 | if (user == null)
40 | {
41 | throw new ApiException(404, Messages.UserNotFound);
42 | }
43 | var mappeduser = _mapper.Map(user);
44 | return new DataResponse(mappeduser, 200);
45 | }
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/TaskManagementAPP/Business/Handlers/Users/Queries/GetUserByEmailQuery.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using Business.Constants;
3 | using Core.Exceptions;
4 | using Core.Utilities.Responses.Abstract;
5 | using Core.Utilities.Responses.Concrete;
6 | using Entities.Concrete;
7 | using Entities.Dtos;
8 | using MediatR;
9 | using Microsoft.AspNetCore.Identity;
10 | using System;
11 | using System.Collections.Generic;
12 | using System.Linq;
13 | using System.Text;
14 | using System.Threading.Tasks;
15 |
16 | namespace Business.Handlers.Users.Queries
17 | {
18 | public class GetUserByEmailQuery:IRequest
19 | {
20 | public string Email { get; set; }
21 | public GetUserByEmailQuery(string email)
22 | {
23 | Email = email;
24 | }
25 | public class GetUserByEmailQueryHandler : IRequestHandler
26 | {
27 | private UserManager _userManager;
28 | private IMapper _mapper;
29 |
30 | public GetUserByEmailQueryHandler(UserManager userManager, IMapper mapper)
31 | {
32 | _userManager = userManager;
33 | _mapper = mapper;
34 | }
35 |
36 | public async Task Handle(GetUserByEmailQuery request, CancellationToken cancellationToken)
37 | {
38 | var user = await _userManager.FindByEmailAsync(request.Email);
39 | if (user == null)
40 | {
41 | throw new ApiException(404, Messages.UserNotFound);
42 | }
43 | var mappeduser = _mapper.Map(user);
44 | return new DataResponse(mappeduser, 200);
45 | }
46 | }
47 | }
48 |
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/TaskManagementAPP/Business/Handlers/Users/Validations/LoginValidator.cs:
--------------------------------------------------------------------------------
1 | using Business.Handlers.Users.Commands;
2 | using FluentValidation;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 |
9 | namespace Business.Handlers.Users.Validations
10 | {
11 | public class LoginValidator:AbstractValidator
12 | {
13 | public LoginValidator()
14 | {
15 | RuleFor(x => x.UserName).NotEmpty().WithMessage("UserName is required");
16 | RuleFor(x => x.Password).NotEmpty().WithMessage("Password is required");
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/TaskManagementAPP/Business/Handlers/Users/Validations/RegisterValidator.cs:
--------------------------------------------------------------------------------
1 | using Business.Handlers.Users.Commands;
2 | using FluentValidation;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 |
9 | namespace Business.Handlers.Users.Validations
10 | {
11 | public class RegisterValidator : AbstractValidator
12 | {
13 | public RegisterValidator()
14 | {
15 | RuleFor(x => x.UserName).NotEmpty();
16 | RuleFor(x => x.FirstName).NotEmpty();
17 | RuleFor(x => x.LastName).NotEmpty();
18 | RuleFor(x => x.Email).NotEmpty().EmailAddress();
19 | RuleFor(x => x.Password).NotEmpty();
20 | RuleFor(x => x.ConfirmPassword).NotEmpty();
21 | RuleFor(x => x).Custom((x, context) =>
22 | {
23 | if (x.Password != x.ConfirmPassword)
24 | {
25 | context.AddFailure(nameof(x.Password), "Passwords should match");
26 | }
27 | });
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/TaskManagementAPP/Business/Mappings/Automapper.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using Business.Handlers.Tasks.Commands;
3 | using Business.Handlers.Users.Commands;
4 | using Entities.Concrete;
5 | using Entities.Dtos;
6 | using TaskStatus = Entities.Concrete.TaskStatus;
7 | using Task = Entities.Concrete.Task;
8 | using Business.Handlers.Comments.Commands;
9 |
10 | namespace Business.Mappings
11 | {
12 | public class Automapper : Profile
13 | {
14 | public Automapper()
15 | {
16 | CreateMap().ReverseMap();
17 | CreateMap().ReverseMap();
18 | CreateMap().ReverseMap();
19 | CreateMap().ReverseMap();
20 | CreateMap().ReverseMap();
21 | CreateMap().ReverseMap();
22 | CreateMap().ReverseMap();
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/TaskManagementAPP/Business/Services/Abstract/ITokenService.cs:
--------------------------------------------------------------------------------
1 | using Entities.Concrete;
2 | using Entities.Dtos;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 |
9 | namespace Business.Services.Abstract
10 | {
11 | public interface ITokenService
12 | {
13 | Task CreateToken (User user);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/TaskManagementAPP/Business/Services/Concrete/TokenManager.cs:
--------------------------------------------------------------------------------
1 | using Business.Services.Abstract;
2 | using Core.Configurations;
3 | using Core.Utilities.Helpers;
4 | using Entities.Concrete;
5 | using Entities.Dtos;
6 | using Microsoft.AspNetCore.Identity;
7 | using Microsoft.Extensions.Options;
8 | using System;
9 | using System.Collections.Generic;
10 | using System.IdentityModel.Tokens.Jwt;
11 | using System.Linq;
12 | using System.Security.Claims;
13 | using System.Security.Cryptography;
14 | using System.Text;
15 | using System.Threading.Tasks;
16 |
17 | namespace Business.Services.Concrete
18 | {
19 | public class TokenManager : ITokenService
20 | {
21 | private readonly JWTOptions _jwtOptions;
22 | private readonly UserManager _userManager;
23 | public TokenManager(IOptions options, UserManager userManager)
24 | {
25 | _jwtOptions = options.Value;
26 | _userManager = userManager;
27 | }
28 |
29 | public async Task CreateToken(User user)
30 | {
31 | var accessTokenExpiration = DateTime.Now.AddMinutes(_jwtOptions.AccessTokenExpiration);
32 | var refreshTokenExpiration = DateTime.Now.AddMinutes(_jwtOptions.RefreshTokenExpiration);
33 | var securityKey = SecurityKeyHelper.GetSymmetricSecurityKey(_jwtOptions.SecurityKey);
34 | var signingCredentials = SigningCredentialsHelper.CreateSigningCredentials(securityKey);
35 |
36 |
37 | JwtSecurityToken jwtSecurityToken = new JwtSecurityToken(
38 | issuer: _jwtOptions.Issuer,
39 | audience: _jwtOptions.Audience[0],
40 | expires: accessTokenExpiration,
41 | notBefore: DateTime.Now,
42 | claims: await GetClaims(user, _jwtOptions.Audience),
43 | signingCredentials: signingCredentials);
44 |
45 | var handler = new JwtSecurityTokenHandler();
46 |
47 | var token = handler.WriteToken(jwtSecurityToken);
48 |
49 | var tokenDto = new TokenDTO
50 | {
51 | AccessToken = token,
52 | AccessTokenExpiration = accessTokenExpiration,
53 | };
54 |
55 | return tokenDto;
56 | }
57 | private async Task> GetClaims(User user, List audiences)
58 | {
59 | var roles = await _userManager.GetRolesAsync(user);
60 | var claims = new List
61 | {
62 | new Claim(ClaimTypes.Email,user.Email),
63 | new Claim(ClaimTypes.Name,user.UserName),
64 | new Claim(ClaimTypes.NameIdentifier,user.Id),
65 | new Claim(JwtRegisteredClaimNames.Jti,Guid.NewGuid().ToString())
66 | };
67 | foreach (var role in roles)
68 | {
69 | claims.Add(new Claim(ClaimTypes.Role, role));
70 | }
71 | claims.AddRange(audiences.Select(x => new Claim(JwtRegisteredClaimNames.Aud, x)));
72 | return claims;
73 | }
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/TaskManagementAPP/Core/Aspects/Autofac/Validation/ValidationAspect.cs:
--------------------------------------------------------------------------------
1 | using Castle.DynamicProxy;
2 | using Core.CrossCuttingConcerns.Validation.FluentValidation;
3 | using Core.Utilities.Interceptors;
4 | using Core.Utilities.Responses.Concrete;
5 | using FluentValidation;
6 | using System;
7 | using System.Collections.Generic;
8 | using System.Linq;
9 | using System.Text;
10 |
11 | namespace Core.Aspects.Autofac.Validation
12 | {
13 | public class ValidationAspect : MethodInterception
14 | {
15 | private readonly Type _validatorType;
16 | public ValidationAspect(Type validatorType)
17 | {
18 | if (!typeof(IValidator).IsAssignableFrom(validatorType))
19 | {
20 | throw new ArgumentException("Wrong validator type");
21 | }
22 | _validatorType = validatorType;
23 | }
24 | protected override void OnBefore(IInvocation invocation)
25 | {
26 | var validator = (IValidator)Activator.CreateInstance(_validatorType);
27 | var entityType = _validatorType.BaseType.GetGenericArguments()[0];
28 | var entities = invocation.Arguments.Where(t => t.GetType() == entityType);
29 | foreach (var entity in entities)
30 | {
31 | ValidatonTool.FluentValidate(validator, entity);
32 | }
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/TaskManagementAPP/Core/Configurations/EmailSettings.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 Core.Configurations
8 | {
9 | public class EmailSettings
10 | {
11 | public string Email { get; set; }
12 | public string Password { get; set; }
13 | public string Host { get; set; }
14 | public int Port { get; set; }
15 | public bool EnableSSL { get; set; }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/TaskManagementAPP/Core/Configurations/JWTOptions.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 Core.Configurations
8 | {
9 | public class JWTOptions
10 | {
11 | public List Audience { get; set; }
12 | public string Issuer { get; set; }
13 | public int AccessTokenExpiration { get; set; }
14 | public int RefreshTokenExpiration { get; set; }
15 | public string SecurityKey { get; set; }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/TaskManagementAPP/Core/Core.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net6.0
5 | enable
6 | disable
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/TaskManagementAPP/Core/CrossCuttingConcerns/Logging/ErrorLog.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace Core.CrossCuttingConcerns.Logging
6 | {
7 | public class ErrorLog
8 | {
9 | public string UserId { get; set; }
10 | public string Username { get; set; }
11 | public string ManagerName { get; set; }
12 | public string MethodName { get; set; }
13 | public List Errors { get; set; }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/TaskManagementAPP/Core/CrossCuttingConcerns/Logging/LogDetail.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace Core.CrossCuttingConcerns.Logging
6 | {
7 | public class LogDetail
8 | {
9 | public string UserId { get; set; }
10 | public string Username { get; set; }
11 | public string ManagerName { get; set; }
12 | public string MethodName { get; set; }
13 | public object Data { get; set; }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/TaskManagementAPP/Core/CrossCuttingConcerns/Logging/SeriLog/ConfigurationModels/PostgreSqlConfiguration.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 Core.CrossCuttingConcerns.Logging.SeriLog.ConfigurationModels
8 | {
9 | public class PostgreSqlConfiguration
10 | {
11 | public string ConnectionString { get; set; }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/TaskManagementAPP/Core/CrossCuttingConcerns/Logging/SeriLog/LoggerServiceBase.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using Serilog;
5 |
6 | namespace Core.CrossCuttingConcerns.Logging.SeriLog
7 | {
8 | public abstract class LoggerServiceBase
9 | {
10 | public ILogger Logger;
11 | public void Verbose(string message) => Logger.Verbose(message);
12 | public void Fatal(string message) => Logger.Fatal(message);
13 | public void Info(string message) => Logger.Information(message);
14 | public void Warn(string message) => Logger.Warning(message);
15 | public void Debug(string message) => Logger.Debug(message);
16 | public void Error(string message) => Logger.Error(message);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/TaskManagementAPP/Core/CrossCuttingConcerns/Logging/SeriLog/Loggers/PostgreSqlLogger.cs:
--------------------------------------------------------------------------------
1 | using Core.CrossCuttingConcerns.Logging.SeriLog.ConfigurationModels;
2 | using Core.Utilities.IoC;
3 | using Microsoft.Extensions.Configuration;
4 | using Microsoft.Extensions.DependencyInjection;
5 | using Serilog;
6 | using Serilog.Sinks.PostgreSQL;
7 | using System;
8 | using System.Collections.Generic;
9 | using System.Linq;
10 | using System.Text;
11 | using System.Threading.Tasks;
12 |
13 | namespace Core.CrossCuttingConcerns.Logging.SeriLog.Loggers
14 | {
15 | public class PostgreSqlLogger:LoggerServiceBase
16 | {
17 | public PostgreSqlLogger()
18 | {
19 | var configuration = ServiceTool.ServiceProvider.GetService();
20 |
21 | var logConfig = configuration.GetSection("SeriLogConfigurations:PostgreSqlConfiguration")
22 | .Get() ?? throw new Exception("PostgreSQLConnectionString is null");
23 | var seriLogConfig = new LoggerConfiguration()
24 | .WriteTo.PostgreSQL(connectionString: logConfig.ConnectionString,tableName:"Logs",needAutoCreateTable:true)
25 | .CreateLogger();
26 | Logger = seriLogConfig;
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/TaskManagementAPP/Core/CrossCuttingConcerns/Validation/FluentValidation/ValidationTool.cs:
--------------------------------------------------------------------------------
1 | using Core.Utilities;
2 | using FluentValidation;
3 | using FluentValidation.TestHelper;
4 | using System;
5 | using System.Collections.Generic;
6 | using System.IO;
7 | using System.Linq;
8 | using System.Net;
9 | using System.Text;
10 |
11 | namespace Core.CrossCuttingConcerns.Validation.FluentValidation
12 | {
13 | public class ValidatonTool
14 | {
15 | public static void FluentValidate(IValidator validator, object entity)
16 | {
17 | var context = new ValidationContext