public Track[] GetPlaylistTracks(int ID)
        {
            //Sorting mess
            PlayList organizer = new PlayList(ID);
            organizer.PlayListSyncOrder();
            List<Track> orderedList = new List<Track>();
            List<Track> unorderedList = DataAccess.Instance.GetTracksInPlaylist(ID);
            Track hold;

            for (int i = 0; i < organizer.PlayListTrackIds.Count; i++)
            {
                hold = unorderedList.Find(x => x.TrackId == organizer.PlayListTrackIds[i]);
                orderedList.Add(hold);
            }

            return orderedList.ToArray<Track>();
            //return DataAccess.Instance.GetTracksInPlaylist(ID).ToArray<Track>();
        }
        public void ReloadPlaylistTracksListBox()
        {
            PlayList selectedPlaylist;
            string song, artist;

            if (ddlPlaylistSelection.SelectedIndex > 0)
            {
                selectedPlaylist = new PlayList((currentUser.MyPlaylistIds)[ddlPlaylistSelection.SelectedIndex - 1]);
                selectedPlaylist.PlayListSyncOrder();
                Session["PlaylistId"] = selectedPlaylist.PlaylistID;
                cbxEditPlaylistPublic.Checked = selectedPlaylist.IsPublic;

                //populates listbox lbPlaylistTracks with tracks from the actively selected playlist
                lbPlaylistTracks.Items.Clear();
                for (int i = 0; i < selectedPlaylist.PlayListTrackIds.Count; i++)
                {
                    song = DataAccess.Instance.GetSongName(selectedPlaylist.PlayListTrackIds[i]);
                    artist = DataAccess.Instance.GetArtist(selectedPlaylist.PlayListTrackIds[i]);
                    lbPlaylistTracks.Items.Add(new ListItem(song + "          -  " + artist, i.ToString()));
                }
            }
            else
                Session["PlaylistId"] = null;
        }
Beispiel #3
0
        public bool CreateUserPlaylist(string name, bool isPublic)
        {
            bool duplicateName = false;

            for (int i = 0; i < _myPlaylistIds.Count; i++)
                if (name == DataAccess.Instance.GetPlayListName(_myPlaylistIds[i]))
                    duplicateName = true;

            if (duplicateName == true)
            {
                //duplicate playlist name attempt
                return false;
            }
            else
            {
                List<int> updateMyPlaylistIds;
                PlayList createdPlaylist = new PlayList(name, _id, isPublic);
                updateMyPlaylistIds = _myPlaylistIds;
                updateMyPlaylistIds.Add(createdPlaylist.PlaylistID);

                return true;
            }
        }
        protected void ddlPublicPlaylist_Change(object sender, EventArgs e)
        {
            PlayList selectedPublicList;
            string song, artist;

            //determines which list to read from for selected playlist
            if (ddlPublicPlayList.SelectedIndex > 0 && ddlPublicPlayList.SelectedValue != "default2")
            {
                if (ddlPublicPlayList.SelectedIndex <= hero.PublicPlayListIds.Count)
                    selectedPublicList = new PlayList((hero.PublicPlayListIds)[ddlPublicPlayList.SelectedIndex - 1]);
                else
                    selectedPublicList = new PlayList((hero.MyPublicPlayListIds)[ddlPublicPlayList.SelectedIndex - 2 - hero.PublicPlayListIds.Count]);

                selectedPublicList.PlayListSyncOrder();

                //populates listbox lbxPublicPlaylistTracks with tracks from the actively selected playlist
                lbxPublicPlaylistTracks.Items.Clear();
                for (int i = 0; i < selectedPublicList.PlayListTrackIds.Count; i++)
                {
                    song = DataAccess.Instance.GetSongName(selectedPublicList.PlayListTrackIds[i]);
                    artist = DataAccess.Instance.GetArtist(selectedPublicList.PlayListTrackIds[i]);
                    lbxPublicPlaylistTracks.Items.Add(new ListItem(song + "          -  " + artist, i.ToString()));
                }
            }
        }