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

namespace ErsatzTV.Controllers.Api.Requests;

public record CreateRerunCollectionRequest(
    string Name,
    CollectionType CollectionType,
    int SelectedId,
    PlaybackOrder FirstRunPlaybackOrder,
    PlaybackOrder RerunPlaybackOrder)
{
    public CreateRerunCollection ToCommand()
    {
        (MediaCollectionViewModel collection,
                MultiCollectionViewModel multiCollection,
                SmartCollectionViewModel smartCollection,
                NamedMediaItemViewModel mediaItem) =
            RerunCollectionRequestMapping.ResolveSelection(CollectionType, SelectedId);

        return new CreateRerunCollection(
            Name,
            CollectionType,
            collection,
            multiCollection,
            smartCollection,
            mediaItem,
            FirstRunPlaybackOrder,
            RerunPlaybackOrder);
    }
}
