using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Music.Model;
using Music.Presentation.Playlist;
using Music.Presentation.Navigation;

namespace Music.Presentation
{
    public class SongDetailPresenter : ISongDetailPresenter
    {
        private ISongDetailView _view;
        private SongService _songService;
        private IPlaylist _playlist;
        private IPageNavigator _pageNavigator;

        public SongDetailPresenter(ISongDetailView view,
            SongService songService, IPlaylist playlist, IPageNavigator pageNavigator)
        {
            _view = view;
            _songService = songService;
            _playlist = playlist;
            _pageNavigator = pageNavigator;
        }

        public void Display()
        {
            Song song = _songService.GetSongBy(_view.SongId);
            
            _view.SongTitle = song.Title;
            _view.AlbumName = song.AlbumName;
            _view.ArtistName = song.ArtistName;
            _view.Genre = song.Genre;
            _view.Track = song.Track;

            _view.ArtistList = _songService.GetAllArtists();
            _view.AlbumList = _songService.GetAllAlbums();
        }

        public void AddSongToPlaylistAndShowPlaylistPage()
        {
            Song song = _songService.GetSongBy(_view.SongId);
            _playlist.Add(song);
            _pageNavigator.NavigateTo(PageDirectory.Playlist);
        }

    }
}
