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

This commit is contained in:
masoodafar-web
2026-02-10 23:01:49 +03:30
parent b42d9e141d
commit d1ca72300d
13 changed files with 77 additions and 95 deletions
@@ -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()