Refactor user ID handling in command handlers and update Protobuf package version to 0.0.124

This commit is contained in:
masoodafar-web
2025-11-20 23:18:07 +03:30
parent 0867244888
commit 8f25757307
18 changed files with 38 additions and 22 deletions

View File

@@ -19,7 +19,7 @@ public class AcceptContractCommandHandler : IRequestHandler<AcceptContractComman
await _context.UserContract.CreateNewUserContractAsync(new CreateNewUserContractRequest()
{
SignGuid = request.SignGuid,
UserId = long.Parse(_currentUserService.UserId ?? throw new InvalidOperationException()),
UserId = _currentUserService.UserId ?? throw new InvalidOperationException(),
ContractId = 1,
SignedPdfFile = request.ContractHtml,
}, cancellationToken: cancellationToken);

View File

@@ -15,7 +15,7 @@ public class SetPasswordForUserCommandHandler : IRequestHandler<SetPasswordForUs
public async Task<Unit> Handle(SetPasswordForUserCommand request, CancellationToken cancellationToken)
{
var setPasswordRequest = request.Adapt<SetPasswordForUserRequest>();
setPasswordRequest.UserId = long.Parse(_currentUserService.UserId ?? throw new InvalidOperationException());
setPasswordRequest.UserId = _currentUserService.UserId ?? throw new InvalidOperationException();
await _context.User.SetPasswordForUserAsync(setPasswordRequest, cancellationToken: cancellationToken);
return new Unit();

View File

@@ -15,12 +15,12 @@ public class GetUserQueryHandler : IRequestHandler<GetUserQuery, GetUserResponse
var userId = _currentUserService.UserId ?? throw new ForbiddenAccessException();
var response = await _context.User.GetUserAsync(request: new()
{
Id = long.Parse(userId)
Id = userId
}, cancellationToken: cancellationToken);
var result = response.Adapt<GetUserResponseDto>();
var getJwtToken = await _context.User.GetJwtTokenAsync(request: new()
{
Id = long.Parse(userId)
Id = userId
}, cancellationToken: cancellationToken);
if(getJwtToken != null && !string.IsNullOrWhiteSpace(getJwtToken.Token))
result.Token = getJwtToken.Token;