-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
52 changed files
with
372 additions
and
902 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
Nezam.EES.Shared/Domain/Identity/User/DomainEvents/UserEmailUpdatedEvent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using Payeh.SharedKernel.Domain.DomainEvents; | ||
|
||
namespace Nezam.EEs.Shared.Domain.Identity.User.DomainEvents; | ||
|
||
public class UserEmailUpdatedEvent : DomainEvent | ||
{ | ||
public UserId UserId { get; } | ||
public string? NewEmail { get; } | ||
|
||
public UserEmailUpdatedEvent(UserId userId, string? newEmail) | ||
{ | ||
UserId = userId; | ||
NewEmail = newEmail; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
Nezam.EES.Shared/Domain/Identity/User/DomainEvents/UserNameUpdatedEvent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using Payeh.SharedKernel.Domain.DomainEvents; | ||
|
||
namespace Nezam.EEs.Shared.Domain.Identity.User.DomainEvents; | ||
|
||
public class UserNameUpdatedEvent : DomainEvent | ||
{ | ||
public UserId UserId { get; } | ||
public string NewUserName { get; } | ||
|
||
public UserNameUpdatedEvent(UserId userId, string newUserName) | ||
{ | ||
UserId = userId; | ||
NewUserName = newUserName; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
Nezam.EES.Shared/Domain/Identity/User/DomainEvents/UserPasswordUpdatedEvent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using Payeh.SharedKernel.Domain.DomainEvents; | ||
|
||
namespace Nezam.EEs.Shared.Domain.Identity.User.DomainEvents; | ||
|
||
public class UserPasswordUpdatedEvent : DomainEvent | ||
{ | ||
public UserId UserId { get; } | ||
|
||
public UserPasswordUpdatedEvent(UserId userId) | ||
{ | ||
UserId = userId; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
Nezam.EES.Shared/Domain/Identity/User/DomainEvents/UserProfileUpdatedEvent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using Nezam.EEs.Shared.Domain.Identity.User.ValueObjects; | ||
using Payeh.SharedKernel.Domain.DomainEvents; | ||
|
||
namespace Nezam.EEs.Shared.Domain.Identity.User.DomainEvents; | ||
|
||
public class UserProfileUpdatedEvent : DomainEvent | ||
{ | ||
public UserId UserId { get; } | ||
public UserProfileValue? NewProfile { get; } | ||
|
||
public UserProfileUpdatedEvent(UserId userId, UserProfileValue? newProfile) | ||
{ | ||
UserId = userId; | ||
NewProfile = newProfile; | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
Nezam.EES.Slice.Identity/Application/UseCases/Roles/GetRoles/GetRolesRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
Nezam.EES.Slice.Identity/Application/UseCases/Roles/GetRoles/GetRolesResponse.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
Nezam.EES.Slice.Identity/Application/UseCases/Users/GetUsers/GetUsersRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
Nezam.EES.Slice.Identity/Application/UseCases/Users/GetUsers/GetUsersResponse.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 0 additions & 7 deletions
7
....Slice.Secretariat/Applciation/UseCases/Documents/GetMyDocuments/GetMyDocumentsRequest.cs
This file was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
...Slice.Secretariat/Applciation/UseCases/Documents/GetMyDocuments/GetMyDocumentsResponse.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
...Slice.Secretariat/Application/EventHandlers/Users/UserProfileUpdatedDomainEventHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
using MediatR; | ||
using Nezam.EEs.Shared.Domain.Identity.User.DomainEvents; | ||
using Nezam.EES.Slice.Secretariat.Domains.Participant; | ||
using Nezam.EES.Slice.Secretariat.Domains.Participant.Repositories; | ||
using Payeh.SharedKernel.UnitOfWork; | ||
|
||
namespace Nezam.EES.Slice.Secretariat.Application.EventHandlers.Users; | ||
|
||
public class UserProfileUpdatedDomainEventHandler : INotificationHandler<UserProfileUpdatedEvent> | ||
{ | ||
private readonly IParticipantRepository _participantRepository; | ||
private readonly IUnitOfWorkManager _unitOfWorkManager; | ||
|
||
public UserProfileUpdatedDomainEventHandler(IParticipantRepository participantRepository, | ||
IUnitOfWorkManager unitOfWorkManager) | ||
{ | ||
_participantRepository = participantRepository; | ||
_unitOfWorkManager = unitOfWorkManager; | ||
} | ||
|
||
public async Task Handle(UserProfileUpdatedEvent notification, CancellationToken cancellationToken) | ||
{ | ||
using var uow = _unitOfWorkManager.Begin(); | ||
|
||
try | ||
{ | ||
// Check if a participant already exists for the given user ID | ||
var existingParticipant = await _participantRepository.FindOneAsync( | ||
p => p.UserId == notification.UserId); | ||
|
||
if (existingParticipant != null) | ||
{ | ||
// Update the existing participant | ||
if (notification.NewProfile != null) | ||
{ | ||
existingParticipant.UpdateName( | ||
$"{notification.NewProfile.FirstName} {notification.NewProfile.LastName}"); | ||
await _participantRepository.UpdateAsync(existingParticipant, autoSave: true); | ||
} | ||
} | ||
else | ||
{ | ||
// Create a new participant | ||
if (notification.NewProfile != null) | ||
{ | ||
var newParticipant = new Participant( | ||
$"{notification.NewProfile.FirstName} {notification.NewProfile.LastName}"); | ||
newParticipant.UpdateUserId(notification.UserId); | ||
await _participantRepository.AddAsync(newParticipant, autoSave: true); | ||
} | ||
} | ||
await uow.CommitAsync(cancellationToken); | ||
} | ||
catch (Exception ex) | ||
{ | ||
await uow.RollbackAsync(cancellationToken); | ||
throw new InvalidOperationException("Failed to handle UserCreatedEvent", ex); | ||
} | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
....Slice.Secretariat/Application/UseCases/Documents/CreateDocument/CreateDocumentRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace Nezam.EES.Slice.Secretariat.Application.UseCases.Documents.CreateDocument; | ||
|
||
public record CreateDocumentRequest | ||
( | ||
string Title,string Content,Guid ReceiverParticipantId | ||
); |
Oops, something went wrong.