using MediatR;
using Modules.User.Application.Repositories;

namespace Modules.User.Application.Queries;

public class GetUserProfileQuery : IRequest<Models.UserProfile>
{
    public Guid UserId { get; set; }
}

public class GetUserProfileQueryHandler(IUserQueries userQueries) : IRequestHandler<GetUserProfileQuery, Models.UserProfile>
{
    public async Task<Models.UserProfile> Handle(GetUserProfileQuery request, CancellationToken cancellationToken)
    {
        return await userQueries.GetUserProfileAsync(request.UserId, cancellationToken)
               ?? throw new Exception("User not found");
    }
}