using System.Collections.ObjectModel;
using System.Linq;

namespace Model.Stub;

public class StubAlbum
{
    public StubArtist StubArtist
    {
        get
        {
            return stubArtist;
        }
    }

    private readonly StubArtist stubArtist;

    public ObservableCollection<Album> Albums
    {
        get => albums;
    }

    private readonly ObservableCollection<Album> albums;

    public StubAlbum()
    {
        stubArtist = new StubArtist();

        Album Album1 = new Album("la street", "lastreet.png", StubArtist.GetArtistByName("Critien") ?? new Artist("Critien"), "c'est la street", "plein d'infos1");
        Album Album2 = new Album("la jsp", "oui.png", StubArtist.GetArtistByName("Critien") ?? new Artist("Critien"), "c'est la couri", "plein d'infos2");
        Album Album3 = new Album("la pas le temps", "non.png", StubArtist.GetArtistByName("Poulifer") ?? new Artist("Poulifer"), "c'est pas la street", "plein d'infos3");
        Album Album4 = new Album("la pas le choix", "peutetre.png", StubArtist.GetArtistByName("Credian") ?? new Artist("Credian"), "c'est la parterre", "plein d'infos4");
        albums = new ObservableCollection<Album>()
        {
            Album1, Album2, Album3, Album4
        };
    }

    public ObservableCollection<Album> GetAlbums()
    {
        return albums;
    }
    public Album? GetAlbumByName(string name)
    {
        foreach(Album album in albums)
        {
            if (name == album.Name)
            {
                return album;
            }
        }
        return null;
    }
    public void AddAlbum(Album album)
    {
        albums.Add(album);
    }
    public void RemoveAlbum(Album album)
    {
        albums.Remove(album);
    }
}
