using ErsatzTV.Application.MediaCollections;
using ErsatzTV.Application.MediaItems;
using ErsatzTV.Core.Domain;

namespace ErsatzTV.Controllers.Api.Requests;

public record UpdateRerunCollectionRequest(
    string Name,
    CollectionType CollectionType,
    int SelectedId,
    PlaybackOrder FirstRunPlaybackOrder,
    PlaybackOrder RerunPlaybackOrder)
{
    public UpdateRerunCollection ToCommand(int id, Option<Seq<int>> expectedVersions = default)
    {
        (MediaCollectionViewModel collection,
                MultiCollectionViewModel multiCollection,
                SmartCollectionViewModel smartCollection,
                NamedMediaItemViewModel mediaItem) =
            RerunCollectionRequestMapping.ResolveSelection(CollectionType, SelectedId);

        return new UpdateRerunCollection(
            id,
            Name,
            CollectionType,
            collection,
            multiCollection,
            smartCollection,
            mediaItem,
            FirstRunPlaybackOrder,
            RerunPlaybackOrder,
            expectedVersions);
    }
}
