using ErsatzTV.Application.Scheduling;
using ErsatzTV.Core.Domain.Scheduling;

namespace ErsatzTV.Controllers.Api.Requests;

public record ReplaceBlockRequest(
    string Name,
    int Minutes,
    BlockStopScheduling StopScheduling,
    List<BlockItemRequest> Items)
{
    public ReplaceBlockItems ToCommand(int blockGroupId, int blockId, Option<Seq<int>> expectedVersions = default) =>
        new(
            blockGroupId,
            blockId,
            Name,
            Minutes,
            StopScheduling,
            (Items ?? []).Select((item, index) => item.ToReplaceItem(index)).ToList(),
            expectedVersions);
}
