43 lines
1.0 KiB
C#
43 lines
1.0 KiB
C#
using Harmonia.Core.Data;
|
|
|
|
namespace Harmonia.Core.Playlists;
|
|
|
|
public class PlaylistManager(IRepository<Playlist> 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));
|
|
}
|
|
} |