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
48a31497
Commit
48a31497
authored
Aug 31, 2024
by
hasan khaddour
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix hours work issue
parent
eee081ba
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
53 additions
and
15 deletions
+53
-15
ParticipantAddedEventHandler.cs
...n/Projects/EventsHandlers/ParticipantAddedEventHandler.cs
+4
-0
ParticipantRemovedEventHandler.cs
...Projects/EventsHandlers/ParticipantRemovedEventHandler.cs
+1
-1
ChangeEmployeeParticipationCommandHandler.cs
...articipation/ChangeEmployeeParticipationCommandHandler.cs
+4
-0
RemoveParticipantCommandHandler.cs
...ands/RemoveParticipant/RemoveParticipantCommandHandler.cs
+6
-2
Employee.cs
PSManagement.Domain/Employees/Entities/Employee.cs
+12
-0
Project.cs
PSManagement.Domain/Projects/Entities/Project.cs
+26
-12
No files found.
PSManagement.Application/Projects/EventsHandlers/ParticipantAddedEventHandler.cs
View file @
48a31497
...
...
@@ -6,6 +6,7 @@ using PSManagement.Domain.Projects.DomainEvents;
using
PSManagement.Domain.Projects.Entities
;
using
PSManagement.Domain.Projects.Repositories
;
using
PSManagement.SharedKernel.DomainEvents
;
using
PSManagement.SharedKernel.Interfaces
;
using
PSManagement.SharedKernel.Specification
;
using
System
;
using
System.Collections.Generic
;
...
...
@@ -21,6 +22,7 @@ namespace PSManagement.Application.Projects.EventsHandlers
private
readonly
IEmailService
_emailService
;
private
readonly
IEmployeesRepository
_employeesRepository
;
private
readonly
IProjectsRepository
_projectsRepository
;
private
readonly
IUnitOfWork
_unitofwork
;
private
readonly
BaseSpecification
<
Employee
>
_specification
;
public
ParticipantAddedEventHandler
(
IEmployeesRepository
employeesRepository
,
...
...
@@ -40,6 +42,8 @@ namespace PSManagement.Application.Projects.EventsHandlers
Employee
employee
=
await
_employeesRepository
.
GetByIdAsync
(
notification
.
EmployeeId
,
_specification
);
Project
project
=
await
_projectsRepository
.
GetByIdAsync
(
notification
.
ProjectId
);
employee
.
IncreaseWorkHours
(
notification
.
PartialTimeRatio
);
await
_emailService
.
SendAsync
(
employee
.
User
.
Email
,
...
...
PSManagement.Application/Projects/EventsHandlers/ParticipantRemovedEventHandler.cs
View file @
48a31497
PSManagement.Application/Projects/UseCases/Commands/ChangeEmployeeParticipation/ChangeEmployeeParticipationCommandHandler.cs
View file @
48a31497
...
...
@@ -17,6 +17,8 @@ namespace PSManagement.Application.Projects.UseCases.Commands.ChangeProjectManag
private
readonly
IProjectsRepository
_projectsRepository
;
private
readonly
BaseSpecification
<
Project
>
_specification
;
private
readonly
IUnitOfWork
_unitOfWork
;
private
readonly
IEmployeesRepository
_employeesRepository
;
public
ChangeEmployeeParticipationCommandHandler
(
IProjectsRepository
projectsRepository
,
...
...
@@ -32,6 +34,7 @@ namespace PSManagement.Application.Projects.UseCases.Commands.ChangeProjectManag
public
async
Task
<
Result
>
Handle
(
ChangeEmployeeParticipationCommand
request
,
CancellationToken
cancellationToken
)
{
_specification
.
AddInclude
(
e
=>
e
.
EmployeeParticipates
);
_specification
.
AddInclude
(
"EmployeeParticipates.Employee"
);
Project
project
=
await
_projectsRepository
.
GetByIdAsync
(
request
.
ProjectId
,
_specification
);
...
...
@@ -47,6 +50,7 @@ namespace PSManagement.Application.Projects.UseCases.Commands.ChangeProjectManag
}
project
.
ChangeParticipant
(
request
.
ParticipantId
,
request
.
PartialTimeRation
,
request
.
Role
);
...
...
PSManagement.Application/Projects/UseCases/Commands/RemoveParticipant/RemoveParticipantCommandHandler.cs
View file @
48a31497
...
...
@@ -35,6 +35,8 @@ namespace PSManagement.Application.Projects.UseCases.Commands.RemoveParticipant
public
async
Task
<
Result
>
Handle
(
RemoveParticipantCommand
request
,
CancellationToken
cancellationToken
)
{
_specification
.
AddInclude
(
e
=>
e
.
EmployeeParticipates
);
_specification
.
AddInclude
(
"EmployeeParticipates.Employee"
);
Project
project
=
await
_projectsRepository
.
GetByIdAsync
(
request
.
ProjectId
,
_specification
);
if
(
project
is
null
)
...
...
@@ -55,6 +57,8 @@ namespace PSManagement.Application.Projects.UseCases.Commands.RemoveParticipant
return
Result
.
Invalid
(
ProjectsErrors
.
ParticipantUnExistError
);
}
employeeParticipate
.
Employee
.
DecreaseWorkHours
(
employeeParticipate
.
PartialTimeRatio
);
await
_employeeParticipateRepository
.
DeleteAsync
(
employeeParticipate
);
...
...
PSManagement.Domain/Employees/Entities/Employee.cs
View file @
48a31497
...
...
@@ -56,9 +56,21 @@ namespace PSManagement.Domain.Employees.Entities
PersonalInfo
=
personalInfo
;
HIASTId
=
hiastId
;
}
#
endregion
Constructors
#
region
business
logic
encapsulation
public
void
IncreaseWorkHours
(
int
workHours
)
{
UpdateWorkHours
(
Availability
.
CurrentWorkingHours
+
workHours
);
}
public
void
DecreaseWorkHours
(
int
workHours
)
{
UpdateWorkHours
(
Availability
.
CurrentWorkingHours
-
workHours
);
}
public
void
UpdateWorkHours
(
int
workingHour
)
{
...
...
PSManagement.Domain/Projects/Entities/Project.cs
View file @
48a31497
...
...
@@ -266,20 +266,12 @@ namespace PSManagement.Domain.Projects.Entities
#
endregion
State
Transitions
// validating data
// this methods help to hide the buissness rules
// and encapsulate it
#
region
Busines
rules
validators
public
bool
VailedSteps
()
{
int
weightSum
=
0
;
foreach
(
Step
step
in
Steps
)
{
weightSum
+=
step
.
Weight
;
}
return
weightSum
==
100
;
}
// this methods encapsulate participation change
// its publis a domain event
#
region
Participation
Change
Encapsulation
public
void
ChangeParticipant
(
int
participantId
,
int
partialTimeRation
,
string
role
)
{
...
...
@@ -292,6 +284,28 @@ namespace PSManagement.Domain.Projects.Entities
participate
.
Role
=
role
;
participate
.
PartialTimeRatio
=
partialTimeRation
;
participate
.
Employee
.
IncreaseWorkHours
(
partialTimeRation
);
participate
.
Employee
.
DecreaseWorkHours
(
participate
.
PartialTimeRatio
);
}
#
endregion
Participation
Change
Encapsulation
// validating data
// this methods help to hide the buissness rules
// and encapsulate it
#
region
Busines
rules
validators
public
bool
VailedSteps
()
{
int
weightSum
=
0
;
foreach
(
Step
step
in
Steps
)
{
weightSum
+=
step
.
Weight
;
}
return
weightSum
==
100
;
}
public
bool
HasParticipant
(
int
participantId
)
{
...
...
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