using System.Collections.Generic;
using System.Linq;
using ErsatzTV.Application.MediaCollections;

namespace ErsatzTV.Controllers.Api.Requests;

public record UpdateMultiCollectionRequest(string Name, List<MultiCollectionItemRequest> Items)
{
    public UpdateMultiCollection ToCommand(int id, Option<Seq<int>> expectedVersions = default) =>
        new(
            id,
            Name,
            (Items ?? new List<MultiCollectionItemRequest>())
            .Select(i => new UpdateMultiCollectionItem(
                i.CollectionId,
                i.SmartCollectionId,
                i.ScheduleAsGroup,
                i.PlaybackOrder,
                i.Weight))
            .ToList(),
            expectedVersions);
}
