protected void TracksSelectionList_ItemCommand(object sender,
                                                   ListViewCommandEventArgs e)
    {
        if (string.IsNullOrEmpty(PlaylistName.Text))
        {
            MessageUserControl.ShowInfo("Warning", "You must supply a playlist name.");
        }
        else
        {
            //obtain the user name.
            string username = User.Identity.Name;

            //obtain the playlist name
            string playlistname = PlaylistName.Text;

            int trackid = int.Parse(e.CommandArgument.ToString());

            //connect to BLL controller
            //call required method
            //refresh the screen
            //do all this under the user frindly errir handler

            MessageUserControl.TryRun(() =>
            {
                PlaylistTrackController sysmgr = new PlaylistTrackController();

                sysmgr.Add_TrackToPlaylist(playlistname, username, trackid);
                List <UserPlaylistTrack> results = sysmgr.List_TrackForPlaylist(playlistname, username);
                PlayList.DataSource = results;
                PlayList.DataBind();
            }, "Playlist Track Added", "You havce successfully added a new track to your list");
        }
    }
Exemple #2
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();
                });
            }
        }
    }
 protected void MoveTrack(int trackid, int tracknumber, string direction)
 {
     //call the BLL move method
     //refresh the playlist
     MessageUserControl.TryRun(() =>
     {
         PlaylistTrackController sysmgr = new PlaylistTrackController();
         //sysmgr.Add_TrackToPLaylist(playlistname, username, trackid);
         List <UserPlaylistTrack> results = sysmgr.List_TrackForPlaylist(PlaylistName.Text, User.Identity.Name);
         PlayList.DataSource = results;
         PlayList.DataBind();
     }, "Playlist Track Added", "You have successfully added a new track to your list.");
 }
 protected void PlayListFetch_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(PlaylistName.Text))
     {
         MessageUserControl.ShowInfo("Warning", "Playlist Name is required.");
     }
     else
     {
         MessageUserControl.TryRun(() =>
         {
             string username = User.Identity.Name;
             PlaylistTrackController sysmgr    = new PlaylistTrackController();
             List <UserPlaylistTrack> playlist = sysmgr.List_TrackForPlaylist(
                 PlaylistName.Text, username);
             PlayList.DataSource = playlist;
             PlayList.DataBind();
         });
     }
 }
Exemple #5
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();
        });
    }
Exemple #6
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;
                }
            });
        }
    }
Exemple #7
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.");
        }
    }
Exemple #8
0
 public void Setup()
 {
     _playlistTrack = new PlaylistTrackController(CreateUnitOfWork());
 }