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
b68de4f1
Commit
b68de4f1
authored
Aug 26, 2024
by
hasan khaddour
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add event handler for register and notifie cparticipant changes
parent
a95bdaa3
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
87 additions
and
2 deletions
+87
-2
ChangeRegisterationOnParticipationChangedEventHandler.cs
.../ChangeRegisterationOnParticipationChangedEventHandler.cs
+44
-0
NotifieParticipantOnParticipationChangedEventHandler.cs
...s/NotifieParticipantOnParticipationChangedEventHandler.cs
+41
-0
ParticipationChangedEvent.cs
...Domain/Projects/DomainEvents/ParticipationChangedEvent.cs
+1
-1
Project.cs
PSManagement.Domain/Projects/Entities/Project.cs
+1
-1
No files found.
PSManagement.Application/Projects/EventsHandlers/ChangeRegisterationOnParticipationChangedEventHandler.cs
0 → 100644
View file @
b68de4f1
using
PSManagement.Domain.Projects.DomainEvents
;
using
PSManagement.Domain.Projects.Entities
;
using
PSManagement.SharedKernel.DomainEvents
;
using
PSManagement.SharedKernel.Interfaces
;
using
PSManagement.SharedKernel.Repositories
;
using
System.Threading
;
using
System.Threading.Tasks
;
namespace
PSManagement.Application.Projects.EventsHandlers
{
public
class
ChangeRegisterationOnParticipationChangedEventHandler
:
IDomainEventHandler
<
ParticipationChangedEvent
>
{
private
readonly
IRepository
<
ParticipationChange
>
_repository
;
private
readonly
IUnitOfWork
_unitOfWork
;
public
ChangeRegisterationOnParticipationChangedEventHandler
(
IRepository
<
ParticipationChange
>
repository
,
IUnitOfWork
unitOfWork
)
{
_repository
=
repository
;
_unitOfWork
=
unitOfWork
;
}
public
async
Task
Handle
(
ParticipationChangedEvent
notification
,
CancellationToken
cancellationToken
)
{
await
_repository
.
AddAsync
(
new
ParticipationChange
{
PartialTimeAfter
=
notification
.
PartialTimeRatioAfter
,
PartialTimeBefore
=
notification
.
PartialTimeRatioBefore
,
EmployeeId
=
notification
.
ParticipantId
,
ProjectId
=
notification
.
ProjectId
,
ChangeDate
=
notification
.
DateTime
,
RoleAfter
=
notification
.
RoleAfter
,
RoleBefore
=
notification
.
RoleBefore
});
await
_unitOfWork
.
SaveChangesAsync
();
}
}
}
PSManagement.Application/Projects/EventsHandlers/NotifieParticipantOnParticipationChangedEventHandler.cs
0 → 100644
View file @
b68de4f1
using
PSManagement.Application.Contracts.Email
;
using
PSManagement.Domain.Employees.Entities
;
using
PSManagement.Domain.Employees.Repositories
;
using
PSManagement.Domain.Projects.DomainEvents
;
using
PSManagement.SharedKernel.DomainEvents
;
using
PSManagement.SharedKernel.Specification
;
using
System.Threading
;
using
System.Threading.Tasks
;
namespace
PSManagement.Application.Projects.EventsHandlers
{
public
class
NotifieParticipantOnParticipationChangedEventHandler
:
IDomainEventHandler
<
ParticipationChangedEvent
>
{
private
readonly
IEmailService
_emailService
;
private
readonly
IEmployeesRepository
_employeeRepository
;
private
readonly
BaseSpecification
<
Employee
>
_specification
;
public
NotifieParticipantOnParticipationChangedEventHandler
(
IEmailService
emailService
,
IEmployeesRepository
employeeRepository
)
{
_emailService
=
emailService
;
_employeeRepository
=
employeeRepository
;
}
public
async
Task
Handle
(
ParticipationChangedEvent
notification
,
CancellationToken
cancellationToken
)
{
_specification
.
AddInclude
(
e
=>
e
.
User
);
Employee
employee
=
await
_employeeRepository
.
GetByIdAsync
(
notification
.
ParticipantId
,
_specification
);
await
_emailService
.
SendAsync
(
employee
.
User
.
Email
,
"Participation Change"
,
"Mr,"
+
employee
.
PersonalInfo
.
FirstName
+
"your particiaption changed to "
+
notification
.
RoleAfter
+
notification
.
PartialTimeRatioAfter
);
}
}
}
PSManagement.Domain/Projects/DomainEvents/ParticipationChanged.cs
→
PSManagement.Domain/Projects/DomainEvents/ParticipationChanged
Event
.cs
View file @
b68de4f1
...
...
@@ -3,7 +3,7 @@ using System;
namespace
PSManagement.Domain.Projects.DomainEvents
{
public
record
ParticipationChanged
(
public
record
ParticipationChanged
Event
(
int
ParticipantId
,
int
PartialTimeRatioBefore
,
int
PartialTimeRatioAfter
,
...
...
PSManagement.Domain/Projects/Entities/Project.cs
View file @
b68de4f1
...
...
@@ -221,7 +221,7 @@ namespace PSManagement.Domain.Projects.Entities
public
void
ChangeParticipant
(
int
participantId
,
int
partialTimeRation
,
string
role
)
{
var
participate
=
EmployeeParticipates
.
Where
(
e
=>
e
.
EmployeeId
==
participantId
).
FirstOrDefault
();
AddDomainEvent
(
new
ParticipationChanged
(
AddDomainEvent
(
new
ParticipationChanged
Event
(
participantId
,
participate
.
PartialTimeRatio
,
partialTimeRation
,
role
,
participate
.
Role
,
Id
,
DateTime
.
Now
));
...
...
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