using LiteCqrs;

namespace TeleWave.Application.Media.MovieImport;

public sealed class MatchMoviesQueryHandler(MovieMatcher matcher)
    : IQueryHandler<MatchMoviesQuery, IReadOnlyList<MovieMatchDto>>
{
    public Task<IReadOnlyList<MovieMatchDto>> Handle(
        MatchMoviesQuery query,
        CancellationToken cancellationToken
    ) => matcher.MatchAsync(query.Names, query.Provider, cancellationToken);
}

public sealed class MatchMovieQueryHandler(MovieMatcher matcher)
    : IQueryHandler<MatchMovieQuery, MovieMatchDto>
{
    public Task<MovieMatchDto> Handle(MatchMovieQuery query, CancellationToken cancellationToken) =>
        matcher.MatchQueryAsync(
            query.Name,
            query.Title,
            query.Year,
            query.Provider,
            cancellationToken
        );
}
