namespace Model;

public class Playlist
{
    public string Name
    {
        get => name;

        set
        {
            if (value != null && value.Length < 75)
            {
                name = value;
            }
        }
    }

    private string name;

    public string Description
    {
        get => description;

        set
        {
            if (value != null && value.Length < 500)
            {
                description = value;
            }
        }
    }

    private string description;

    public IEnumerable<Title> Morceaux { get; set; }

    public string ImageURL
    {
        get => imageURL;

        set
        {
            if (value != null && value.Contains('.'))
            {
                imageURL = value;
            }
        }
    }

    private string imageURL;

    public Playlist(string nom, string description, string imageURL)
    {
        Name = nom;
        Description = description;
        Morceaux = new List<Title>();
        this.imageURL = imageURL;
    }

    public void AddTitle(Title morceau)
    {
        Morceaux.Prepend(morceau);
    }

    public void RemoveTitle(Title morceau)
    {
        Morceaux.ToList().Remove(morceau);
    }

}
