2025-09-27 10:36:00 +03:30
|
|
|
namespace FrontOffice.BFF.Application.UserCQ.Queries.GetUser;
|
|
|
|
|
public class GetUserQueryHandler : IRequestHandler<GetUserQuery, GetUserResponseDto>
|
|
|
|
|
{
|
|
|
|
|
private readonly IApplicationContractContext _context;
|
2025-09-28 00:55:35 +03:30
|
|
|
private readonly ICurrentUserService _currentUserService;
|
2025-09-27 10:36:00 +03:30
|
|
|
|
2025-09-28 00:55:35 +03:30
|
|
|
public GetUserQueryHandler(IApplicationContractContext context, ICurrentUserService currentUserService)
|
2025-09-27 10:36:00 +03:30
|
|
|
{
|
|
|
|
|
_context = context;
|
2025-09-28 00:55:35 +03:30
|
|
|
_currentUserService = currentUserService;
|
2025-09-27 10:36:00 +03:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<GetUserResponseDto> Handle(GetUserQuery request, CancellationToken cancellationToken)
|
|
|
|
|
{
|
2025-09-28 00:55:35 +03:30
|
|
|
var userId = _currentUserService.UserId ?? throw new ForbiddenAccessException();
|
|
|
|
|
var response = await _context.User.GetUserAsync(request: new()
|
|
|
|
|
{
|
|
|
|
|
Id = long.Parse(userId)
|
|
|
|
|
}, cancellationToken: cancellationToken);
|
|
|
|
|
return response.Adapt<GetUserResponseDto>();
|
2025-09-27 10:36:00 +03:30
|
|
|
}
|
|
|
|
|
}
|