-
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
126 changed files
with
2,118 additions
and
346 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
4 changes: 2 additions & 2 deletions
4
New/Payeh.SharedKernel/EntityFrameworkCore/UnitofWork/EfCoreDbContextProvider.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
4 changes: 1 addition & 3 deletions
4
New/Payeh.SharedKernel/UnitOfWork/Null/NullUnitOfWorkManager.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
35 changes: 0 additions & 35 deletions
35
...s/Secretariat/Nezam.Modular.ESS.Secretariat.Domain/Documents/DocumentActivityLogEntity.cs
This file was deleted.
Oops, something went wrong.
86 changes: 0 additions & 86 deletions
86
...ules/Secretariat/Nezam.Modular.ESS.Secretariat.Domain/Documents/DocumentReferralEntity.cs
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
76 changes: 76 additions & 0 deletions
76
Nezam.EES.Slice.Identity/Application/UseCases/Users/AssignRoles/AssignRolesEndpoint.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,76 @@ | ||
using Consul; | ||
using FastEndpoints; | ||
using Nezam.EES.Service.Identity.Domains.Roles.DomainServices; | ||
using Nezam.EES.Service.Identity.Domains.Users; | ||
using Nezam.EES.Service.Identity.Domains.Users.DomainServices; | ||
using Nezam.EEs.Shared.Domain.Identity.Roles; | ||
using Nezam.EEs.Shared.Domain.Identity.User; | ||
using Payeh.SharedKernel.UnitOfWork; | ||
|
||
namespace Nezam.EES.Service.Identity.Application.UseCases.Users.AssignRoles; | ||
|
||
public class AssignRolesEndpoint : Endpoint<AssignRolesRecord> | ||
{ | ||
private readonly IUserDomainService _userDomainService; | ||
private readonly IRoleDomainService _roleDomainService; | ||
private readonly IUnitOfWorkManager _unitOfWork; | ||
|
||
public AssignRolesEndpoint(IUserDomainService userDomainService, IRoleDomainService roleDomainService, IUnitOfWorkManager unitOfWork) | ||
{ | ||
_userDomainService = userDomainService; | ||
_roleDomainService = roleDomainService; | ||
_unitOfWork = unitOfWork; | ||
} | ||
|
||
public override void Configure() | ||
{ | ||
Put("/api/users/{id:guid}/assign-roles"); | ||
} | ||
|
||
public override async Task HandleAsync(AssignRolesRecord req, CancellationToken ct) | ||
{ | ||
var userIdGuid = Route<Guid>("id", true); | ||
var userId = UserId.NewId(userIdGuid); | ||
|
||
using var uow = _unitOfWork.Begin(); | ||
try | ||
{ | ||
var existingUserResult = await _userDomainService.GetUserByIdAsync(userId); | ||
|
||
if (existingUserResult.IsFailure) | ||
{ | ||
ThrowError("User not found."); | ||
} | ||
|
||
var existingUser = existingUserResult.Data; | ||
|
||
// Retrieve roles by IDs from the request | ||
var roleIds = req.Roles.Select(RoleId.NewId).ToArray(); | ||
|
||
|
||
|
||
|
||
var updateResult = await _userDomainService.AssignRoleAsync(existingUser,roleIds); | ||
|
||
if (updateResult.IsFailure) | ||
{ | ||
await SendErrorsAsync(cancellation: ct); | ||
return; | ||
} | ||
|
||
await uow.CommitAsync(ct); | ||
|
||
await SendOkAsync(ct); | ||
} | ||
catch (Exception ex) | ||
{ | ||
await uow.RollbackAsync(ct); | ||
ThrowError($"Error while assigning roles to user: {ex.Message}"); | ||
} | ||
} | ||
} | ||
|
||
public record AssignRolesRecord | ||
{ | ||
public List<string> Roles { get; set; } = new(); | ||
} |
57 changes: 57 additions & 0 deletions
57
Nezam.EES.Slice.Identity/Application/UseCases/Users/CreateUser/CreateUserEndpoint.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,57 @@ | ||
using FastEndpoints; | ||
using Nezam.EES.Service.Identity.Domains.Users; | ||
using Nezam.EES.Service.Identity.Domains.Users.DomainServices; | ||
using Nezam.EEs.Shared.Domain.Identity.User; | ||
using Nezam.EEs.Shared.Domain.Identity.User.ValueObjects; | ||
using Payeh.SharedKernel.UnitOfWork; | ||
|
||
namespace Nezam.EES.Service.Identity.Application.UseCases.Users.CreateUser; | ||
|
||
public class CreateUserEndpoint : Endpoint<CreateUserRecord> | ||
{ | ||
private readonly IUserDomainService _userDomainService; | ||
private readonly IUnitOfWorkManager _unitOfWork; | ||
|
||
public CreateUserEndpoint(IUserDomainService roleDomainService, IUnitOfWorkManager unitOfWork) | ||
{ | ||
_userDomainService = roleDomainService; | ||
_unitOfWork = unitOfWork; | ||
} | ||
|
||
public override void Configure() | ||
{ | ||
Post("/api/users"); | ||
|
||
} | ||
|
||
public override async Task HandleAsync(CreateUserRecord req, CancellationToken ct) | ||
{ | ||
if (string.IsNullOrWhiteSpace(req.UserName)) | ||
{ | ||
ThrowError("UserName cannot be empty."); | ||
} | ||
|
||
using var uow = _unitOfWork.Begin(); | ||
try | ||
{ | ||
|
||
var user = new UserEntity(UserId.NewId(), UserNameId.NewId(req.UserName),new UserPasswordValue(req.Password),new UserProfileValue(req.FirstName,req.LastName),new UserEmailValue(req.Email)); | ||
var createResult = await _userDomainService.Create(user); | ||
|
||
if (createResult.IsFailure) | ||
{ | ||
await SendErrorsAsync(cancellation: ct); | ||
return; | ||
} | ||
// ذخیره تغییرات | ||
await uow.CommitAsync(ct); | ||
|
||
await SendOkAsync(ct); | ||
} | ||
catch (Exception ex) | ||
{ | ||
await uow.RollbackAsync(ct); | ||
ThrowError($"Error while updating role: {ex.Message}"); | ||
} | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
Nezam.EES.Slice.Identity/Application/UseCases/Users/CreateUser/CreateUserRecord.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,3 @@ | ||
namespace Nezam.EES.Service.Identity.Application.UseCases.Users.CreateUser; | ||
|
||
public record CreateUserRecord(string UserName,string Password,string FirstName,string LastName,string Email); |
Oops, something went wrong.