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
4ea3732a
Commit
4ea3732a
authored
Aug 19, 2024
by
hasan khaddour
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update some handlers logic
parent
8000595b
Changes
20
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
307 additions
and
34 deletions
+307
-34
MapperConfiguration.cs
...Application/ApplicationDTOsMappers/MapperConfiguration.cs
+3
-1
AuthenticationResult.cs
...lication/Contracts/Authentication/AuthenticationResult.cs
+10
-2
IOccupancySystemNotifier.cs
...plication/Contracts/Occupancy/IOccupancySystemNotifier.cs
+14
-0
ICurrentUserProvider.cs
...t.Application/Contracts/Providers/ICurrentUserProvider.cs
+13
-0
EmployeeWorkHoursChangedEventHandler.cs
...es/EventsHandlers/EmployeeWorkHoursChangedEventHandler.cs
+20
-0
UpdateEmployeeWorkHoursCommandHandler.cs
...mployeeWorkHours/UpdateEmployeeWorkHoursCommandHandler.cs
+13
-2
PSManagement.Application.csproj
PSManagement.Application/PSManagement.Application.csproj
+1
-1
ParticipantAddedEventHandler.cs
...n/Projects/EventsHandlers/ParticipantAddedEventHandler.cs
+58
-0
ParticipantRemovedEventHandler.cs
...Projects/EventsHandlers/ParticipantRemovedEventHandler.cs
+46
-0
ProjectApprovedEventHandler.cs
...on/Projects/EventsHandlers/ProjectApprovedEventHandler.cs
+17
-0
ProjectCreatedEventHandler.cs
...ion/Projects/EventsHandlers/ProjectCreatedEventHandler.cs
+25
-3
AddAttachmentCommandHandler.cs
...ses/Commands/AddAttachment/AddAttachmentCommandHandler.cs
+23
-6
ApproveProjectCommandHandler.cs
...s/Commands/ApproveProject/ApproveProjectCommandHandler.cs
+2
-2
CancelProjectCommandHandler.cs
...ses/Commands/CancelProject/CancelProjectCommandHandler.cs
+3
-2
CompletePlaningProjectCommandHandler.cs
...etePlaningProject/CompletePlaningProjectCommandHandler.cs
+2
-2
CompleteProgressProjectCommandHandler.cs
...eProgressProject/CompleteProgressProjectCommandHandler.cs
+4
-10
RemoveParticipantCommandHandler.cs
...ands/RemoveParticipant/RemoveParticipantCommandHandler.cs
+3
-2
GetProjectByIdQuery.cs
...ts/UseCases/Queries/GetProjectById/GetProjectByIdQuery.cs
+1
-1
GetProjectByIdQueryHandler.cs
...ases/Queries/GetProjectById/GetProjectByIdQueryHandler.cs
+2
-0
TrackCompletedEventHandler.cs
...ation/Tracks/EventsHandlers/TrackCompletedEventHandler.cs
+47
-0
No files found.
PSManagement.Application/ApplicationDTOsMappers/MapperConfiguration.cs
View file @
4ea3732a
using
AutoMapper
;
using
PSManagement.Application.Contracts.Authentication
;
using
PSManagement.Application.Customers.Common
;
using
PSManagement.Application.Employees.Common
;
using
PSManagement.Application.FinancialSpends.Common
;
...
...
@@ -12,6 +13,7 @@ using PSManagement.Domain.Customers.Entities;
using
PSManagement.Domain.Customers.ValueObjects
;
using
PSManagement.Domain.Employees.Entities
;
using
PSManagement.Domain.FinancialSpends.Entities
;
using
PSManagement.Domain.Identity.Entities
;
using
PSManagement.Domain.Projects.Entities
;
using
PSManagement.Domain.Projects.ValueObjects
;
using
PSManagement.Domain.Tracking
;
...
...
@@ -81,7 +83,7 @@ namespace PSManagement.Application.Mappers
))
;
CreateMap
<
Role
,
RoleDTO
>().
ReverseMap
();
}
}
...
...
PSManagement.Application/Contracts/Authentication/AuthenticationResult.cs
View file @
4ea3732a
...
...
@@ -10,12 +10,20 @@ namespace PSManagement.Application.Contracts.Authentication
{
public
class
AuthenticationResult
{
public
int
Id
{
get
;
set
;
}
public
int
Employee
Id
{
get
;
set
;
}
public
String
Email
{
get
;
set
;
}
public
String
LastName
{
get
;
set
;
}
public
String
FirstName
{
get
;
set
;
}
public
ICollection
<
Role
>
Roles
{
get
;
set
;
}
public
ICollection
<
Role
DTO
>
Roles
{
get
;
set
;
}
public
String
Token
{
get
;
set
;
}
}
public
class
RoleDTO
{
public
String
Name
{
get
;
set
;
}
public
int
Id
{
get
;
set
;
}
}
}
PSManagement.Application/Contracts/Occupancy/IOccupancySystemNotifier.cs
0 → 100644
View file @
4ea3732a
using
PSManagement.Domain.Tracking
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
PSManagement.Application.Contracts.Occupancy
{
public
interface
IOccupancySystemNotifier
{
public
Task
SendEmployeeOccupancyNotification
(
EmployeeTrack
employeeTrack
);
}
}
PSManagement.Application/Contracts/Providers/ICurrentUserProvider.cs
0 → 100644
View file @
4ea3732a
using
PSManagement.Application.Contracts.Authentication
;
using
System.Collections.Generic
;
namespace
PSManagement.Application.Contracts.Providers
{
public
interface
ICurrentUserProvider
{
int
?
EmployeeId
{
get
;
}
string
Email
{
get
;
}
int
?
HiastId
{
get
;
}
IEnumerable
<
string
>
Roles
{
get
;
}
}
}
PSManagement.Application/Employees/EventsHandlers/EmployeeWorkHoursChangedEventHandler.cs
0 → 100644
View file @
4ea3732a
using
PSManagement.Domain.Employees.DomainEvents
;
using
PSManagement.SharedKernel.DomainEvents
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading
;
using
System.Threading.Tasks
;
namespace
PSManagement.Application.Employees.EventsHandlers
{
public
class
EmployeeWorkHoursChangedEventHandler
:
IDomainEventHandler
<
EmployeeWorkHoursChangedEvent
>
{
public
Task
Handle
(
EmployeeWorkHoursChangedEvent
notification
,
CancellationToken
cancellationToken
)
{
return
Task
.
CompletedTask
;
}
}
}
PSManagement.Application/Employees/UseCases/Commands/UpdateEmployeeWorkHours/UpdateEmployeeWorkHoursCommandHandler.cs
View file @
4ea3732a
...
...
@@ -3,6 +3,7 @@ using PSManagement.Domain.Employees.DomainErrors;
using
PSManagement.Domain.Employees.Entities
;
using
PSManagement.Domain.Employees.Repositories
;
using
PSManagement.SharedKernel.CQRS.Command
;
using
PSManagement.SharedKernel.Interfaces
;
using
System.Threading
;
using
System.Threading.Tasks
;
...
...
@@ -12,24 +13,34 @@ namespace PSManagement.Application.Employees.UseCases.Commands.UpdateEmployeeWor
{
private
readonly
IEmployeesRepository
_employeesRepository
;
private
readonly
static
int
_workHourLimit
=
70
;
private
readonly
IUnitOfWork
_unitOfWork
;
public
UpdateEmployeeWorkHoursCommandHandler
(
IEmployeesRepository
employeesRepository
)
public
UpdateEmployeeWorkHoursCommandHandler
(
IEmployeesRepository
employeesRepository
,
IUnitOfWork
unitOfWork
)
{
_employeesRepository
=
employeesRepository
;
_unitOfWork
=
unitOfWork
;
}
public
async
Task
<
Result
>
Handle
(
UpdateEmployeeWorkHoursCommand
request
,
CancellationToken
cancellationToken
)
{
Employee
employee
=
await
_employeesRepository
.
GetByIdAsync
(
request
.
EmployeeId
);
if
(
employee
is
null
)
{
return
Result
.
Invalid
(
EmployeesErrors
.
EmployeeUnExist
);
}
// check the work hours limitation boundries
if
(
request
.
WorkingHour
<
_workHourLimit
&&
request
.
WorkingHour
>
0
)
{
employee
.
Availability
=
new
(
request
.
WorkingHour
,
employee
.
Availability
.
IsAvailable
);
// this method will publish the events of changing the work hours
employee
.
UpdateWorkHours
(
request
.
WorkingHour
);
await
_employeesRepository
.
UpdateAsync
(
employee
);
await
_unitOfWork
.
SaveChangesAsync
();
return
Result
.
Success
();
}
else
{
...
...
PSManagement.Application/PSManagement.Application.csproj
View file @
4ea3732a
...
...
@@ -7,7 +7,7 @@
<ItemGroup>
<Folder Include="Behaviors\AuthorizationBehavior\" />
<Folder Include="
Tracks\EventsHandlers
\" />
<Folder Include="
Projects\UseCases\Commands\ChangeParticipantPartialTime
\" />
</ItemGroup>
<ItemGroup>
...
...
PSManagement.Application/Projects/EventsHandlers/ParticipantAddedEventHandler.cs
0 → 100644
View file @
4ea3732a
using
PSManagement.Application.Contracts.Email
;
using
PSManagement.Domain.Employees.Entities
;
using
PSManagement.Domain.Employees.Repositories
;
using
PSManagement.Domain.Employees.Specification
;
using
PSManagement.Domain.Projects.DomainEvents
;
using
PSManagement.Domain.Projects.Entities
;
using
PSManagement.Domain.Projects.Repositories
;
using
PSManagement.SharedKernel.DomainEvents
;
using
PSManagement.SharedKernel.Specification
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading
;
using
System.Threading.Tasks
;
namespace
PSManagement.Application.Projects.EventsHandlers
{
public
class
ParticipantAddedEventHandler
:
IDomainEventHandler
<
ParticipantAddedEvent
>
{
private
readonly
IEmailService
_emailService
;
private
readonly
IEmployeesRepository
_employeesRepository
;
private
readonly
IProjectsRepository
_projectsRepository
;
private
readonly
BaseSpecification
<
Employee
>
_specification
;
public
ParticipantAddedEventHandler
(
IEmployeesRepository
employeesRepository
,
IEmailService
emailService
,
IProjectsRepository
projectsRepository
)
{
_employeesRepository
=
employeesRepository
;
_emailService
=
emailService
;
_specification
=
new
EmployeesSpecification
();
_projectsRepository
=
projectsRepository
;
}
public
async
Task
Handle
(
ParticipantAddedEvent
notification
,
CancellationToken
cancellationToken
)
{
_specification
.
AddInclude
(
e
=>
e
.
User
);
Employee
employee
=
await
_employeesRepository
.
GetByIdAsync
(
notification
.
EmployeeId
,
_specification
);
Project
project
=
await
_projectsRepository
.
GetByIdAsync
(
notification
.
ProjectId
);
await
_emailService
.
SendAsync
(
employee
.
User
.
Email
,
"Project Participation "
,
"Hello Mr."
+
employee
.
PersonalInfo
.
FirstName
+
" you have a new participation in the project "
+
project
.
ProjectInfo
.
Name
+
" with the role "
+
notification
.
Role
+
" with the partial time ratio "
+
notification
.
PartialTimeRatio
+
" \n"
);
}
}
}
PSManagement.Application/Projects/EventsHandlers/ParticipantRemovedEventHandler.cs
0 → 100644
View file @
4ea3732a
using
PSManagement.Application.Contracts.Email
;
using
PSManagement.Domain.Employees.Entities
;
using
PSManagement.Domain.Employees.Repositories
;
using
PSManagement.Domain.Employees.Specification
;
using
PSManagement.Domain.Projects.DomainEvents
;
using
PSManagement.Domain.Projects.Entities
;
using
PSManagement.Domain.Projects.Repositories
;
using
PSManagement.SharedKernel.DomainEvents
;
using
PSManagement.SharedKernel.Specification
;
using
System.Threading
;
using
System.Threading.Tasks
;
namespace
PSManagement.Application.Projects.EventsHandlers
{
public
class
ParticipantRemovedEventHandler
:
IDomainEventHandler
<
ParticipantRemovedEvent
>
{
private
readonly
IEmailService
_emailService
;
private
readonly
IEmployeesRepository
_employeesRepository
;
private
readonly
IProjectsRepository
_projectsRepository
;
private
readonly
BaseSpecification
<
Employee
>
_specification
;
public
ParticipantRemovedEventHandler
(
IEmployeesRepository
employeesRepository
,
IEmailService
emailService
,
IProjectsRepository
projectsRepository
)
{
_employeesRepository
=
employeesRepository
;
_emailService
=
emailService
;
_specification
=
new
EmployeesSpecification
();
_projectsRepository
=
projectsRepository
;
}
public
async
Task
Handle
(
ParticipantRemovedEvent
notification
,
CancellationToken
cancellationToken
)
{
_specification
.
AddInclude
(
e
=>
e
.
User
);
Employee
employee
=
await
_employeesRepository
.
GetByIdAsync
(
notification
.
EmployeeId
,
_specification
);
Project
project
=
await
_projectsRepository
.
GetByIdAsync
(
notification
.
ProjectId
);
await
_emailService
.
SendAsync
(
employee
.
User
.
Email
,
"Participation Cancelled"
,
"we are sorry Mr."
+
employee
.
PersonalInfo
.
FirstName
+
" but you are removed from the project "
+
project
.
ProjectInfo
.
Name
);
}
}
}
PSManagement.Application/Projects/EventsHandlers/ProjectApprovedEventHandler.cs
0 → 100644
View file @
4ea3732a
using
PSManagement.Domain.Projects.DomainEvents
;
using
PSManagement.SharedKernel.DomainEvents
;
using
System.Threading
;
using
System.Threading.Tasks
;
namespace
PSManagement.Application.Projects.EventsHandlers
{
public
class
ProjectApprovedEventHandler
:
IDomainEventHandler
<
ProjectApprovedEvent
>
{
public
Task
Handle
(
ProjectApprovedEvent
notification
,
CancellationToken
cancellationToken
)
{
return
Task
.
CompletedTask
;
}
}
}
PSManagement.Application/Projects/EventsHandlers/ProjectCreatedEventHandler.cs
View file @
4ea3732a
using
PSManagement.Application.Contracts.Email
;
using
PSManagement.Domain.Employees.Entities
;
using
PSManagement.Domain.Employees.Repositories
;
using
PSManagement.Domain.Employees.Specification
;
using
PSManagement.Domain.Projects.DomainEvents
;
using
PSManagement.SharedKernel.DomainEvents
;
using
PSManagement.SharedKernel.Specification
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
...
...
@@ -13,17 +17,35 @@ namespace PSManagement.Application.Projects.EventsHandlers
public
class
ProjectCreatedEventHandler
:
IDomainEventHandler
<
ProjectCreatedEvent
>
{
private
readonly
IEmailService
_emailService
;
private
readonly
IEmployeesRepository
_employeesRepository
;
private
readonly
BaseSpecification
<
Employee
>
_specification
;
public
ProjectCreatedEventHandler
(
IEmailService
emailService
)
public
ProjectCreatedEventHandler
(
IEmailService
emailService
,
IEmployeesRepository
employeesRepository
)
{
_emailService
=
emailService
;
_employeesRepository
=
employeesRepository
;
_specification
=
new
EmployeesSpecification
();
}
public
async
Task
Handle
(
ProjectCreatedEvent
notification
,
CancellationToken
cancellationToken
)
{
_specification
.
AddInclude
(
e
=>
e
.
User
);
await
_emailService
.
SendAsync
(
""
+
notification
.
ProjectManagerId
,
"gf h gf "
,
"fg fdg"
);
await
_emailService
.
SendAsync
(
""
+
notification
.
TeamLeaderId
,
"gf h gf "
,
"fg fdg"
);
Employee
projectManager
=
await
_employeesRepository
.
GetByIdAsync
(
notification
.
ProjectManagerId
,
_specification
);
Employee
teamLeader
=
await
_employeesRepository
.
GetByIdAsync
(
notification
.
TeamLeaderId
,
_specification
);
await
_emailService
.
SendAsync
(
projectManager
.
User
.
Email
,
"Manage a new Project "
,
"Mr"
+
projectManager
.
PersonalInfo
.
FirstName
+
" you are chosen to Manage a new Project \n "
);
await
_emailService
.
SendAsync
(
teamLeader
.
User
.
Email
,
"Lead a new Project "
,
"Mr"
+
teamLeader
.
PersonalInfo
.
FirstName
+
" you are chosen to lead a new Project \n "
);
}
}
...
...
PSManagement.Application/Projects/UseCases/Commands/AddAttachment/AddAttachmentCommandHandler.cs
View file @
4ea3732a
using
Ardalis.Result
;
using
PSManagement.Application.Contracts.Storage
;
using
PSManagement.Domain.Projects
;
using
PSManagement.Domain.Projects.Builders
;
using
PSManagement.Domain.Projects.DomainErrors
;
using
PSManagement.Domain.Projects.Entities
;
...
...
@@ -7,6 +8,7 @@ using PSManagement.Domain.Projects.Repositories;
using
PSManagement.SharedKernel.CQRS.Command
;
using
PSManagement.SharedKernel.Interfaces
;
using
PSManagement.SharedKernel.Repositories
;
using
PSManagement.SharedKernel.Specification
;
using
System
;
using
System.Threading
;
using
System.Threading.Tasks
;
...
...
@@ -18,6 +20,7 @@ namespace PSManagement.Application.Projects.UseCases.Commands.AddAttachment
private
readonly
IRepository
<
Attachment
>
_attachmentRepository
;
private
readonly
IUnitOfWork
_unitOfWork
;
private
readonly
IProjectsRepository
_projectsRepository
;
private
readonly
BaseSpecification
<
Project
>
_specification
;
public
AddAttachmentCommandHandler
(
IFileService
fileService
,
...
...
@@ -29,25 +32,39 @@ namespace PSManagement.Application.Projects.UseCases.Commands.AddAttachment
_attachmentRepository
=
repository
;
_unitOfWork
=
unitOfWork
;
_projectsRepository
=
projectsRepository
;
_specification
=
new
ProjectSpecification
();
}
public
async
Task
<
Result
<
int
>>
Handle
(
AddAttachmentCommand
request
,
CancellationToken
cancellationToken
)
{
_specification
.
AddInclude
(
e
=>
e
.
Attachments
);
// save the file on the uploaded files
Result
<
string
>
pathResult
=
await
_fileService
.
StoreFile
(
request
.
AttachmentName
+
Guid
.
NewGuid
(),
request
.
File
);
Project
project
=
await
_projectsRepository
.
GetByIdAsync
(
request
.
ProjectId
);
if
(
project
is
null
)
{
return
Result
.
Invalid
(
ProjectsErrors
.
InvalidEntryError
);
}
// check if the file uploaded
if
(
pathResult
.
IsSuccess
)
{
// get the project
Project
project
=
await
_projectsRepository
.
GetByIdAsync
(
request
.
ProjectId
,
_specification
);
// checking if the project exist
if
(
project
is
null
)
{
return
Result
.
Invalid
(
ProjectsErrors
.
InvalidEntryError
);
}
Attachment
attachment
=
new
(
pathResult
.
Value
,
request
.
AttachmentName
,
request
.
AttachmentDescription
,
request
.
ProjectId
);
attachment
=
await
_attachmentRepository
.
AddAsync
(
attachment
);
project
.
AddAttachment
(
pathResult
.
Value
,
request
.
AttachmentName
,
request
.
AttachmentDescription
,
request
.
ProjectId
);
await
_unitOfWork
.
SaveChangesAsync
();
return
Result
.
Success
(
attachment
.
Id
);
}
else
{
return
Result
.
Invalid
(
pathResult
.
ValidationErrors
);
}
}
...
...
PSManagement.Application/Projects/UseCases/Commands/ApproveProject/ApproveProjectCommandHandler.cs
View file @
4ea3732a
...
...
@@ -35,10 +35,10 @@ namespace PSManagement.Application.Projects.UseCases.Commands.ApproveProject
else
{
project
.
Approve
(
request
.
ProjectAggreement
);
Result
result
=
project
.
Approve
(
request
.
ProjectAggreement
);
await
_unitOfWork
.
SaveChangesAsync
();
return
Result
.
Success
()
;
return
result
;
...
...
PSManagement.Application/Projects/UseCases/Commands/CancelProject/CancelProjectCommandHandler.cs
View file @
4ea3732a
...
...
@@ -37,10 +37,11 @@ namespace PSManagement.Application.Projects.UseCases.Commands.CancelProject
else
{
project
.
Cancel
(
_dateTime
.
UtcNow
);
Result
result
=
project
.
Cancel
(
_dateTime
.
UtcNow
);
await
_unitOfWork
.
SaveChangesAsync
();
return
Result
.
Success
()
;
return
result
;
...
...
PSManagement.Application/Projects/UseCases/Commands/CompletePlaningProject/CompletePlaningProjectCommandHandler.cs
View file @
4ea3732a
...
...
@@ -35,11 +35,11 @@ namespace PSManagement.Application.Projects.UseCases.Commands.CompletePlaningPro
else
{
project
.
Plan
();
Result
result
=
project
.
Plan
();
await
_unitOfWork
.
SaveChangesAsync
();
return
Result
.
Success
()
;
return
result
;
...
...
PSManagement.Application/Projects/UseCases/Commands/CompleteProgressProject/CompleteProgressProjectCommandHandler.cs
View file @
4ea3732a
...
...
@@ -32,17 +32,11 @@ namespace PSManagement.Application.Projects.UseCases.Commands.CompleteProgressPr
{
return
Result
.
Invalid
(
ProjectsErrors
.
InvalidEntryError
);
}
else
{
project
.
Complete
();
else
{
Result
result
=
project
.
Complete
();
await
_unitOfWork
.
SaveChangesAsync
();
return
Result
.
Success
();
return
result
;
}
}
}
...
...
PSManagement.Application/Projects/UseCases/Commands/RemoveParticipant/RemoveParticipantCommandHandler.cs
View file @
4ea3732a
...
...
@@ -46,9 +46,10 @@ namespace PSManagement.Application.Projects.UseCases.Commands.RemoveParticipant
if
(
project
.
EmployeeParticipates
is
null
)
{
return
Result
.
Invalid
(
ProjectsErrors
.
ParticipantUnExistError
);
}
var
employeeParticipate
=
project
.
EmployeeParticipates
.
Where
(
e
=>
e
.
EmployeeId
==
request
.
ParticipantId
).
FirstOrDefault
();
EmployeeParticipate
employeeParticipate
=
project
.
EmployeeParticipates
.
Where
(
e
=>
e
.
EmployeeId
==
request
.
ParticipantId
).
FirstOrDefault
();
if
(
employeeParticipate
is
null
)
{
return
Result
.
Invalid
(
ProjectsErrors
.
ParticipantUnExistError
);
...
...
PSManagement.Application/Projects/UseCases/Queries/GetProject/GetProjectByIdQuery.cs
→
PSManagement.Application/Projects/UseCases/Queries/GetProject
ById
/GetProjectByIdQuery.cs
View file @
4ea3732a
...
...
@@ -6,7 +6,7 @@ using System.Collections.Generic;
using
System.Linq
;
using
System.Text
;
namespace
PSManagement.Application.Projects.UseCases.Queries.GetProject
namespace
PSManagement.Application.Projects.UseCases.Queries.GetProject
ById
{
public
record
GetProjectByIdQuery
(
int
ProjectId
...
...
PSManagement.Application/Projects/UseCases/Queries/GetProject/GetProjectByIdQueryHandler.cs
→
PSManagement.Application/Projects/UseCases/Queries/GetProject
ById
/GetProjectByIdQueryHandler.cs
View file @
4ea3732a
using
Ardalis.Result
;
using
AutoMapper
;
using
PSManagement.Application.Projects.Common
;
using
PSManagement.Application.Projects.UseCases.Queries.GetProjectById
;
using
PSManagement.Domain.Projects
;
using
PSManagement.Domain.Projects.Entities
;
using
PSManagement.Domain.Projects.Repositories
;
...
...
@@ -34,6 +35,7 @@ namespace PSManagement.Application.Projects.UseCases.Queries.GetProject
_specification
.
Includes
.
Add
(
p
=>
p
.
Attachments
);
_specification
.
Includes
.
Add
(
p
=>
p
.
TeamLeader
);
_specification
.
Includes
.
Add
(
p
=>
p
.
Executer
);
_specification
.
Includes
.
Add
(
p
=>
p
.
Proposer
);
...
...
PSManagement.Application/Tracks/EventsHandlers/TrackCompletedEventHandler.cs
0 → 100644
View file @
4ea3732a
using
PSManagement.Application.Contracts.Occupancy
;
using
PSManagement.Domain.Steps.Repositories
;
using
PSManagement.Domain.Tracking
;
using
PSManagement.Domain.Tracking.DomainEvents
;
using
PSManagement.Domain.Tracking.Specification
;
using
PSManagement.SharedKernel.DomainEvents
;
using
PSManagement.SharedKernel.Specification
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading
;
using
System.Threading.Tasks
;
namespace
PSManagement.Application.Tracks.EventsHandlers
{
class
TrackCompletedEventHandler
:
IDomainEventHandler
<
TrackCompletedEvent
>
{
private
readonly
IOccupancySystemNotifier
_occupancySystemNotifier
;
private
readonly
ITracksRepository
_trackRepository
;
private
readonly
BaseSpecification
<
Track
>
_specification
;
public
TrackCompletedEventHandler
(
ITracksRepository
trackRepository
,
IOccupancySystemNotifier
occupancySystemNotifier
)
{
_trackRepository
=
trackRepository
;
_occupancySystemNotifier
=
occupancySystemNotifier
;
_specification
=
new
TrackSpecification
();
}
public
async
Task
Handle
(
TrackCompletedEvent
notification
,
CancellationToken
cancellationToken
)
{
_specification
.
AddInclude
(
s
=>
s
.
EmployeeTracks
);
Track
track
=
await
_trackRepository
.
GetByIdAsync
(
notification
.
TrackId
,
_specification
);
foreach
(
EmployeeTrack
employeeTrack
in
track
.
EmployeeTracks
)
{
await
_occupancySystemNotifier
.
SendEmployeeOccupancyNotification
(
employeeTrack
);
}
}
}
}
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