using Domain.Entities; using Domain.Exceptions; using Features.UserManagement.Repository; using MediatR; namespace Features.UserManagement.Queries.GetUserById; /// /// Handles by looking up the matching user account. /// /// Repository used to query user account data. public class GetUserByIdHandler(IUserAccountRepository repository) : IRequestHandler { /// Thrown when no user account exists with the given ID. public async Task Handle(GetUserByIdQuery request, CancellationToken cancellationToken) { var user = await repository.GetByIdAsync(request.UserAccountId); if (user is null) throw new NotFoundException($"User with ID {request.UserAccountId} not found"); return user; } }