using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using Music.Model;

namespace Music.Presentation.Playlist
{
    public class Playlist : IPlaylist
    {
        #region IPlaylist Members

        public IEnumerable<Song> Items
        {
            get
            {
                return GetPlaylistSongs();
            }
        }

        public void Add(Song song)
        {
            IList<Song> songs = GetPlaylistSongs();
            songs.Add(song);
        }

        #endregion

        private IList<Song> GetPlaylistSongs()
        {
            IList<Song> songs =
                HttpContext.Current.Session["Playlist"] as IList<Song>;

            if (songs == null)
            {
                songs = new List<Song>();
                HttpContext.Current.Session["Playlist"] = songs;
            }

            return songs;
        }
    }
}
