namespace Harmonia.Core.Playlists;

public class PlaylistManager(IPlaylistRepository playlistRepository) : IPlaylistManager
{
    private Playlist? _currentPlaylist;
    public Playlist? CurrentPlaylist
    {
        get
        {
            return _currentPlaylist;
        }
        set
        {
            _currentPlaylist = value;
            CurrentPlaylistChanged?.Invoke(this, new());
        }
    }

    public event EventHandler? CurrentPlaylistChanged;
    public event EventHandler<PlaylistAddedEventArgs>? PlaylistAdded;
    public event EventHandler<PlaylistRemovedEventArgs>? PlaylistRemoved;

    public void AddPlaylist()
    {
        Playlist playlist = new()
        {
            Name = "New Playlist"
        };

        playlistRepository.Save(playlist);

        PlaylistAdded?.Invoke(this, new(playlist));
    }

    public void RemovePlaylist(Playlist playlist)
    {
        playlistRepository.Delete(playlist);

        PlaylistRemoved?.Invoke(this, new(playlist));
    }
}