using LiteCqrs;
using TeleWave.Application.Common.Models;

namespace TeleWave.Application.Programming.Templates.Generate;

public sealed class ListGridProfilesQueryHandler
    : IQueryHandler<ListGridProfilesQuery, Result<IReadOnlyList<GridProfileDto>>>
{
    public Task<Result<IReadOnlyList<GridProfileDto>>> Handle(
        ListGridProfilesQuery query,
        CancellationToken cancellationToken
    ) =>
        Task.FromResult(
            Result.Success<IReadOnlyList<GridProfileDto>>([
                .. GridProfiles.All.Select(p => new GridProfileDto(
                    p.Kind,
                    p.Name,
                    p.Reference,
                    p.Description
                )),
            ])
        );
}
