예제 #1
0
    protected void DeleteTrack_Click(object sender, EventArgs e)
    {
        if (CurrentPlayList.Rows.Count == 0)
        {
            MessageUserControl.ShowInfo("You must have a playlist with entries before trying to remove the track.");
        }
        else
        {
            int selectedrowindex = CurrentPlayList.SelectedIndex;

            if (selectedrowindex > -1)
            {
                int customerid  = GetUserCustomerId();
                int trackid     = int.Parse((CurrentPlayList.Rows[selectedrowindex].FindControl("TrackId") as Label).Text);
                int tracknumber = int.Parse((CurrentPlayList.Rows[selectedrowindex].FindControl("TrackNumber") as Label).Text);
                //MessageUserControl.ShowInfo("track is >" + (CurrentPlayList.Rows[selectedrowindex].FindControl("TrackId") as Label).Text + "<");
                MessageUserControl.TryRun(() =>
                {
                    PlaylistTrackController sysmgr = new PlaylistTrackController();
                    sysmgr.RemovePlaylistTrack(PlayListName.Text, trackid, tracknumber, customerid);
                    List <TracksForPlaylist> results = sysmgr.Get_PlaylistTracks(PlayListName.Text, customerid);
                    CurrentPlayList.DataSource       = results;
                    CurrentPlayList.SelectedIndex    = -1;
                    CurrentPlayList.DataBind();
                });
            }
        }
    }
예제 #2
0
    protected void PlayListFetch_Click(object sender, EventArgs e)
    {
        int customerid = GetUserCustomerId();

        if (customerid > 0)
        {
            MessageUserControl.TryRun(() =>
            {
                if (string.IsNullOrEmpty(PlayListName.Text))
                {
                    throw new Exception("Enter a playlist name.");
                }
                else
                {
                    PlaylistTrackController sysmgr   = new PlaylistTrackController();
                    List <TracksForPlaylist> results = sysmgr.Get_PlaylistTracks(PlayListName.Text, customerid);
                    CurrentPlayList.DataSource       = results;
                    CurrentPlayList.DataBind();
                    CurrentPlayList.SelectedIndex = -1;
                }
            });
        }
    }
예제 #3
0
    protected void MoveTrack(int selectedrowindex, string direction)
    {
        int customerid  = GetUserCustomerId();
        int trackid     = int.Parse((CurrentPlayList.Rows[selectedrowindex].FindControl("TrackId") as Label).Text);
        int tracknumber = int.Parse((CurrentPlayList.Rows[selectedrowindex].FindControl("TrackNumber") as Label).Text);

        MessageUserControl.TryRun(() =>
        {
            PlaylistTrackController sysmgr = new PlaylistTrackController();
            sysmgr.MoveTrack(PlayListName.Text, trackid, tracknumber, customerid, direction);
            List <TracksForPlaylist> results = sysmgr.Get_PlaylistTracks(PlayListName.Text, customerid);
            CurrentPlayList.DataSource       = results;
            if (direction.Equals("up"))
            {
                CurrentPlayList.SelectedIndex = selectedrowindex - 1;
            }
            else
            {
                CurrentPlayList.SelectedIndex = selectedrowindex + 1;
            }
            CurrentPlayList.DataBind();
        });
    }
예제 #4
0
    protected void TrackSearchList_ItemCommand(object sender, ListViewCommandEventArgs e)
    {
        int customerid = GetUserCustomerId();

        if (customerid > 0)  //is the user a customer
        {
            ListViewDataItem rowcontents  = e.Item as ListViewDataItem;
            string           playlistname = PlayListName.Text;
            if (string.IsNullOrEmpty(PlayListName.Text))
            {
                MessageUserControl.ShowInfo("Please enter a playlist name.");
            }
            else
            {
                MessageUserControl.TryRun(() =>
                {
                    //the trackid is attached to each ListView row via the CommandArgument parameter

                    //this method does not make the value visible to the user (or in view source unless
                    //   the hacker decompressed the hidden data)

                    //access to the trackid is done via the ListViewCommandEventsArgs e and is treated
                    //as an object, thus it needs to be cast to a string for the Parse to work

                    PlaylistTrackController sysmgr = new PlaylistTrackController();
                    sysmgr.AddTrackToPlayList(playlistname, int.Parse(e.CommandArgument.ToString()), customerid);
                    List <TracksForPlaylist> results = sysmgr.Get_PlaylistTracks(playlistname, customerid);
                    CurrentPlayList.DataSource       = results;
                    CurrentPlayList.DataBind();
                });
            }
        }
        else
        {
            MessageUserControl.ShowInfo("Please use your customer account to manage playlists.");
        }
    }