Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
ProjectsStatusManagement
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hasan.bahjat
ProjectsStatusManagement
Commits
514c14b7
Commit
514c14b7
authored
Aug 08, 2024
by
hasan khaddour
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add CQRS Structure
parent
b7910ea4
Changes
18
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
145 additions
and
31 deletions
+145
-31
ValidationBehavior.cs
...cation/Behaviors/ValidationBehavior/ValidationBehavior.cs
+1
-3
ValidationException.cs
...ment.Application/Common/Exceptions/ValidationException.cs
+0
-14
AuthenticationResult.cs
...lication/Contracts/Authentication/AuthenticationResult.cs
+4
-1
IJwtTokenGenerator.cs
...Application/Contracts/Authorization/IJwtTokenGenerator.cs
+3
-2
IRoleService.cs
...ement.Application/Contracts/Authorization/IRoleService.cs
+19
-0
IUserRoleService.cs
...t.Application/Contracts/Authorization/IUserRoleService.cs
+17
-0
IDateTimeProvider.cs
...ment.Application/Contracts/Providers/IDateTimeProvider.cs
+1
-1
IFileService.cs
PSManagement.Application/Contracts/Storage/IFileService.cs
+15
-0
CustomerDTO.cs
PSManagement.Application/Customers/Common/CustomerDTO.cs
+3
-2
CreateCustomerCommand.cs
...UseCases/Commands/CreateCustomer/CreateCustomerCommand.cs
+1
-1
CreateCustomerCommandHandler.cs
...s/Commands/CreateCustomer/CreateCustomerCommandHandler.cs
+3
-4
UpdateCustomerCommand.cs
...UseCases/Commands/UpdateCustomer/UpdateCustomerCommand.cs
+1
-1
UpdateCustomerCommandHandler.cs
...s/Commands/UpdateCustomer/UpdateCustomerCommandHandler.cs
+1
-1
CustomerMapperConfiguration.cs
...gement.Application/Mappers/CustomerMapperConfiguration.cs
+0
-1
PSManagement.Application.csproj
PSManagement.Application/PSManagement.Application.csproj
+24
-0
ProjectDTO.cs
PSManagement.Application/Projects/Common/ProjectDTO.cs
+6
-0
CreateProjectCommand.cs
...s/UseCases/Commands/CreateProject/CreateProjectCommand.cs
+20
-0
CreateProjectCommandHandler.cs
...ses/Commands/CreateProject/CreateProjectCommandHandler.cs
+26
-0
No files found.
PSManagement.Application/Behaviors/ValidationBehavior/ValidationBehavior.cs
View file @
514c14b7
using
FluentResults
;
using
FluentResults
;
using
FluentValidation
;
using
FluentValidation
;
using
MediatR
;
using
MediatR
;
using
PSManagement.Application.Common.Exceptions
;
using
PSManagement.SharedKernel.CQRS.Command
;
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Linq
;
using
System.Text
;
using
System.Text
;
using
System.Threading
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
using
ValidationException
=
PSManagement
.
Application
.
Common
.
Exceptions
.
ValidationException
;
namespace
PSManagement.Application.Behaviors.ValidationBehavior
namespace
PSManagement.Application.Behaviors.ValidationBehavior
{
{
...
...
PSManagement.Application/Common/Exceptions/ValidationException.cs
deleted
100644 → 0
View file @
b7910ea4
using
PSManagement.SharedKernel.DomainException
;
using
System.Collections.Generic
;
namespace
PSManagement.Application.Common.Exceptions
{
public
sealed
class
ValidationException
:
BadRequestException
{
public
ValidationException
(
Dictionary
<
string
,
string
[
]>
errors
)
:
base
(
"Validation errors occurred"
)
=>
Errors
=
errors
;
public
Dictionary
<
string
,
string
[
]>
Errors
{
get
;
}
}
}
PSManagement.Application/Contracts/Authentication/AuthenticationResult.cs
View file @
514c14b7
using
System
;
using
PSManagement.Domain.Identity.Entities
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Collections.ObjectModel
;
using
System.Linq
;
using
System.Linq
;
using
System.Text
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
...
@@ -12,6 +14,7 @@ namespace PSManagement.Application.Contracts.Authentication
...
@@ -12,6 +14,7 @@ namespace PSManagement.Application.Contracts.Authentication
public
String
Email
{
get
;
set
;
}
public
String
Email
{
get
;
set
;
}
public
String
LastName
{
get
;
set
;
}
public
String
LastName
{
get
;
set
;
}
public
String
FirstName
{
get
;
set
;
}
public
String
FirstName
{
get
;
set
;
}
public
ICollection
<
Role
>
Roles
{
get
;
set
;
}
public
String
Token
{
get
;
set
;
}
public
String
Token
{
get
;
set
;
}
}
}
...
...
PSManagement.Application/Contracts/Authorization/IJwtTokenGenerator.cs
View file @
514c14b7
using
System
;
using
PSManagement.Domain.Identity.Entities
;
using
System
;
namespace
PSManagement.Application.Contracts.Authorization
namespace
PSManagement.Application.Contracts.Authorization
{
{
public
interface
IJwtTokenGenerator
public
interface
IJwtTokenGenerator
{
{
public
String
GenerateToken
(
int
id
,
String
firstName
,
String
lastName
,
String
email
);
public
String
GenerateToken
(
User
user
);
}
}
}
}
PSManagement.Application/Contracts/Authorization/IRoleService.cs
0 → 100644
View file @
514c14b7
using
FluentResults
;
using
PSManagement.Domain.Identity.Entities
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
PSManagement.Application.Contracts.Authorization
{
public
interface
IRoleService
{
Task
<
Result
>
CreateRoleAsync
(
string
roleName
);
Task
<
Result
>
DeleteRoleAsync
(
int
roleId
);
Task
<
List
<
Role
>>
GetRolesAsync
();
Task
<
Result
<
Role
>>
GetRoleByIdAsync
(
int
id
);
Task
<
Result
<
Role
>>
UpdateRole
(
int
id
,
string
roleName
);
}
}
PSManagement.Application/Contracts/Authorization/IUserRoleService.cs
0 → 100644
View file @
514c14b7
using
FluentResults
;
using
System
;
using
System.Collections.Generic
;
using
System.Threading.Tasks
;
namespace
PSManagement.Application.Contracts.Authorization
{
public
interface
IUserRoleService
{
Task
<
bool
>
IsInRoleAsync
(
int
userId
,
string
role
);
Task
<
List
<
string
>>
GetUserRolesAsync
(
string
email
);
Task
<
Result
>
AssignUserToRole
(
string
userName
,
string
roleName
);
Task
UpdateUsersRole
(
string
userName
,
string
usersRole
);
Task
<
Result
>
RemoveUserFromRole
(
string
email
,
string
roleName
);
}
}
PSManagement.Application/Co
mmon
/Providers/IDateTimeProvider.cs
→
PSManagement.Application/Co
ntracts
/Providers/IDateTimeProvider.cs
View file @
514c14b7
...
@@ -4,7 +4,7 @@ using System.Linq;
...
@@ -4,7 +4,7 @@ using System.Linq;
using
System.Text
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
namespace
PSManagement.Application.Co
mmon.Service
s
namespace
PSManagement.Application.Co
ntracts.Provider
s
{
{
public
interface
IDateTimeProvider
public
interface
IDateTimeProvider
{
{
...
...
PSManagement.Application/C
ustomers/Common/AddressDTO
.cs
→
PSManagement.Application/C
ontracts/Storage/IFileService
.cs
View file @
514c14b7
using
System
;
using
FluentResults
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Linq
;
using
System.Text
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
namespace
PSManagement.Application.C
ustomers.Common
namespace
PSManagement.Application.C
ontracts.Storage
{
{
public
record
AddressDTO
(
public
interface
IFileService
int
StreetNumber
,
{
int
ZipCode
,
public
Result
StoreFile
(
string
fileName
);
String
StreetName
,
String
City
);
}
}
}
PSManagement.Application/Customers/Common/CustomerDTO.cs
View file @
514c14b7
using
System
;
using
PSManagement.Domain.Customers.ValueObjects
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Linq
;
using
System.Text
;
using
System.Text
;
...
@@ -10,7 +11,7 @@ namespace PSManagement.Application.Customers.Common
...
@@ -10,7 +11,7 @@ namespace PSManagement.Application.Customers.Common
{
{
public
int
Id
{
get
;
set
;
}
public
int
Id
{
get
;
set
;
}
public
String
CustomerName
{
get
;
set
;
}
public
String
CustomerName
{
get
;
set
;
}
public
Address
DTO
Address
{
get
;
set
;
}
public
Address
Address
{
get
;
set
;
}
public
String
Email
{
get
;
set
;
}
public
String
Email
{
get
;
set
;
}
public
IEnumerable
<
ContactInfoDTO
>
ContactInfo
{
get
;
private
set
;
}
public
IEnumerable
<
ContactInfoDTO
>
ContactInfo
{
get
;
private
set
;
}
...
...
PSManagement.Application/Customers/UseCases/Commands/CreateCustomer/CreateCustomerCommand.cs
View file @
514c14b7
...
@@ -15,7 +15,7 @@ namespace PSManagement.Application.Customers.UseCases.Commands.CreateCustomer
...
@@ -15,7 +15,7 @@ namespace PSManagement.Application.Customers.UseCases.Commands.CreateCustomer
public
record
CreateCustomerCommand
(
public
record
CreateCustomerCommand
(
string
CustomerName
,
string
CustomerName
,
string
Email
,
string
Email
,
Address
DTO
Address
Address
Address
)
:
ICommand
<
Result
<
int
>>;
)
:
ICommand
<
Result
<
int
>>;
}
}
PSManagement.Application/Customers/UseCases/Commands/CreateCustomer/CreateCustomerCommandHandler.cs
View file @
514c14b7
...
@@ -17,16 +17,15 @@ namespace PSManagement.Application.Customers.UseCases.Commands.CreateCustomer
...
@@ -17,16 +17,15 @@ namespace PSManagement.Application.Customers.UseCases.Commands.CreateCustomer
public
class
CreateCustomerCommandHandler
:
ICommandHandler
<
CreateCustomerCommand
,
Result
<
int
>>
public
class
CreateCustomerCommandHandler
:
ICommandHandler
<
CreateCustomerCommand
,
Result
<
int
>>
{
{
private
readonly
ICustomersRepository
_customerRepository
;
private
readonly
ICustomersRepository
_customerRepository
;
private
readonly
IMapper
_mapper
;
public
CreateCustomerCommandHandler
(
ICustomersRepository
customerRepository
,
IMapper
mapper
)
public
CreateCustomerCommandHandler
(
ICustomersRepository
customerRepository
)
{
{
_customerRepository
=
customerRepository
;
_customerRepository
=
customerRepository
;
_mapper
=
mapper
;
}
}
public
async
Task
<
Result
<
int
>>
Handle
(
CreateCustomerCommand
request
,
CancellationToken
cancellationToken
)
public
async
Task
<
Result
<
int
>>
Handle
(
CreateCustomerCommand
request
,
CancellationToken
cancellationToken
)
{
{
Customer
customer
=
new
(
request
.
CustomerName
,
_mapper
.
Map
<
Address
>(
request
.
Address
)
,
request
.
Email
);
Customer
customer
=
new
(
request
.
CustomerName
,
request
.
Address
,
request
.
Email
);
customer
=
await
_customerRepository
.
AddAsync
(
customer
);
customer
=
await
_customerRepository
.
AddAsync
(
customer
);
...
...
PSManagement.Application/Customers/UseCases/Commands/UpdateCustomer/UpdateCustomerCommand.cs
View file @
514c14b7
...
@@ -15,7 +15,7 @@ namespace PSManagement.Application.Customers.UseCases.Commands.UpdateCustomer
...
@@ -15,7 +15,7 @@ namespace PSManagement.Application.Customers.UseCases.Commands.UpdateCustomer
int
CustomerId
,
int
CustomerId
,
String
CustomerName
,
String
CustomerName
,
String
Email
,
String
Email
,
Address
DTO
Address
Address
Address
)
:
ICommand
<
Result
>;
)
:
ICommand
<
Result
>;
}
}
PSManagement.Application/Customers/UseCases/Commands/UpdateCustomer/UpdateCustomerCommandHandler.cs
View file @
514c14b7
...
@@ -26,7 +26,7 @@ namespace PSManagement.Application.Customers.UseCases.Commands.UpdateCustomer
...
@@ -26,7 +26,7 @@ namespace PSManagement.Application.Customers.UseCases.Commands.UpdateCustomer
public
async
Task
<
Result
>
Handle
(
UpdateCustomerCommand
request
,
CancellationToken
cancellationToken
)
public
async
Task
<
Result
>
Handle
(
UpdateCustomerCommand
request
,
CancellationToken
cancellationToken
)
{
{
Customer
customer
=
new
(
request
.
CustomerName
,
_mapper
.
Map
<
Address
>(
request
.
Address
)
,
request
.
Email
);
Customer
customer
=
new
(
request
.
CustomerName
,
request
.
Address
,
request
.
Email
);
customer
.
Id
=
request
.
CustomerId
;
customer
.
Id
=
request
.
CustomerId
;
await
_customerRepository
.
UpdateAsync
(
customer
);
await
_customerRepository
.
UpdateAsync
(
customer
);
...
...
PSManagement.Application/Mappers/CustomerMapperConfiguration.cs
View file @
514c14b7
...
@@ -15,7 +15,6 @@ namespace PSManagement.Application.Mappers
...
@@ -15,7 +15,6 @@ namespace PSManagement.Application.Mappers
{
{
public
CustomerMapperConfiguration
()
public
CustomerMapperConfiguration
()
{
{
CreateMap
<
AddressDTO
,
Address
>().
ReverseMap
();
CreateMap
<
CustomerDTO
,
Customer
>().
ReverseMap
();
CreateMap
<
CustomerDTO
,
Customer
>().
ReverseMap
();
CreateMap
<
ContactInfoDTO
,
ContactInfo
>().
ReverseMap
();
CreateMap
<
ContactInfoDTO
,
ContactInfo
>().
ReverseMap
();
...
...
PSManagement.Application/PSManagement.Application.csproj
View file @
514c14b7
...
@@ -6,6 +6,30 @@
...
@@ -6,6 +6,30 @@
<ItemGroup>
<ItemGroup>
<Folder Include="Behaviors\AuthorizationBehavior\" />
<Folder Include="Behaviors\AuthorizationBehavior\" />
<Folder Include="ProjectsStatus\UseCases\" />
<Folder Include="Projects\UseCases\Commands\AddStep\" />
<Folder Include="Projects\UseCases\Commands\AddFinincialSpending\" />
<Folder Include="Projects\UseCases\Commands\AddParticipant\" />
<Folder Include="Projects\UseCases\Commands\UpdateParticipant\" />
<Folder Include="Projects\UseCases\Commands\UpdateFinincialSpending\" />
<Folder Include="Projects\UseCases\Commands\UpdateProject\" />
<Folder Include="Projects\UseCases\Commands\UpdateStep\" />
<Folder Include="Projects\UseCases\Queries\ListAllProject\" />
<Folder Include="Projects\UseCases\Queries\GetProjectPlan\" />
<Folder Include="Projects\UseCases\Queries\GetProject\" />
<Folder Include="Projects\UseCases\Queries\GetProjectFinicialSpending\" />
<Folder Include="Tracks\UseCaes\Commands\CreateTrack\" />
<Folder Include="Tracks\UseCaes\Commands\AddStepsTrack\" />
<Folder Include="Tracks\UseCaes\Commands\AddEmployeesTrack\" />
<Folder Include="Tracks\UseCaes\Commands\SaveTrack\" />
<Folder Include="Tracks\UseCaes\Commands\UpdateEmployeeTrack\" />
<Folder Include="Tracks\UseCaes\Commands\UpdateStepTrack\" />
<Folder Include="Tracks\UseCaes\Commands\UpdateTrack\" />
<Folder Include="Tracks\UseCaes\Queries\ListAll\" />
<Folder Include="Tracks\UseCaes\Queries\GetTrack\" />
<Folder Include="Tracks\UseCaes\Queries\GetPlanTrack\" />
<Folder Include="Tracks\UseCaes\Queries\GetEmployeesTrack\" />
<Folder Include="Tracks\UseCaes\Queries\GetEmployeeTrack\" />
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ItemGroup>
...
...
PSManagement.Application/Projects/Common/ProjectDTO.cs
0 → 100644
View file @
514c14b7
namespace
PSManagement.Application.Projects.Common
{
public
class
ProjectDTO
{
}
}
\ No newline at end of file
PSManagement.Application/Projects/UseCases/Commands/CreateProject/CreateProjectCommand.cs
0 → 100644
View file @
514c14b7
using
FluentResults
;
using
PSManagement.Application.Projects.Common
;
using
PSManagement.Domain.Projects.ValueObjects
;
using
PSManagement.SharedKernel.CQRS.Command
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
namespace
PSManagement.Application.Projects.UseCases.Commands.CreateProject
{
public
record
CreateProjectCommand
(
ProjectInfo
ProjectInfo
,
ProposalInfo
ProposalInfo
,
Aggreement
ProjectAggreement
,
int
TeamLeaderId
,
int
ProjectManagerId
,
int
ProposerId
)
:
ICommand
<
Result
<
ProjectDTO
>>;
}
PSManagement.Application/Projects/UseCases/Commands/CreateProject/CreateProjectCommandHandler.cs
0 → 100644
View file @
514c14b7
using
FluentResults
;
using
PSManagement.Application.Projects.Common
;
using
PSManagement.Domain.Projects.Repositories
;
using
PSManagement.SharedKernel.CQRS.Command
;
using
System.Threading
;
using
System.Threading.Tasks
;
namespace
PSManagement.Application.Projects.UseCases.Commands.CreateProject
{
public
class
CreateProjectCommandHandler
:
ICommandHandler
<
CreateProjectCommand
,
Result
<
ProjectDTO
>>
{
private
readonly
IProjectsRepository
_projectsRepository
;
public
CreateProjectCommandHandler
(
IProjectsRepository
projectsRepository
)
{
_projectsRepository
=
projectsRepository
;
}
public
Task
<
Result
<
ProjectDTO
>>
Handle
(
CreateProjectCommand
request
,
CancellationToken
cancellationToken
)
{
return
Task
.
FromResult
<
Result
<
ProjectDTO
>>(
Result
.
Fail
(
new
Error
(
""
)));
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment