refactor: Remove ICurrentUserService dependency from query handlers and update user ID handling logic
Build and Deploy to Kubernetes / build-and-deploy (push) Failing after 8s
Build and Deploy to Kubernetes / build-and-deploy (push) Failing after 8s
This commit is contained in:
+5
-7
@@ -2,21 +2,19 @@ namespace CMSMicroservice.Application.UserWalletCQ.Queries.GetUserWallet;
|
||||
public class GetUserWalletQueryHandler : IRequestHandler<GetUserWalletQuery, GetUserWalletResponseDto>
|
||||
{
|
||||
private readonly IApplicationDbContext _context;
|
||||
private readonly ICurrentUserService _currentUser;
|
||||
|
||||
public GetUserWalletQueryHandler(IApplicationDbContext context, ICurrentUserService currentUser)
|
||||
public GetUserWalletQueryHandler(IApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
_currentUser = currentUser;
|
||||
}
|
||||
|
||||
public async Task<GetUserWalletResponseDto> Handle(GetUserWalletQuery request,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
// If Id is 0 or not provided, get the current authenticated user's ID
|
||||
var userId = request.Id == 0
|
||||
? (long.TryParse(_currentUser.UserId, out var currentUserId) ? currentUserId : 0)
|
||||
: request.Id;
|
||||
// UserId must be provided - customer endpoints resolve from JWT before calling
|
||||
var userId = request.Id;
|
||||
if (userId == 0)
|
||||
throw new ArgumentException("UserId is required");
|
||||
|
||||
var response = await _context.UserWallets
|
||||
.AsNoTracking()
|
||||
|
||||
Reference in New Issue
Block a user