Example #1
0
        protected void TracksSelectionList_ItemCommand(object sender,
                                                       ListViewCommandEventArgs e)
        {                                //event on listview - command arg**
            string username = "******"; //until security

            //form event validation - presence
            if (string.IsNullOrEmpty(PlaylistName.Text))
            {
                MessageUserControl.ShowInfo("missing data", "enter a playlist name to playlist name field");
            }
            else
            {
                //playlist exists and arg has happened
                //REMINDER  - Message usercontrol will do error throws

                MessageUserControl.TryRun(() => {
                    //logic for the code block
                    PlaylistTracksController sysmgr = new PlaylistTracksController();
                    // e argument coming from button object in list ... parse e object to string then to int

                    //access a specific field on selected listview row
                    string song = (e.Item.FindControl("NameLabel") as Label).Text;

                    sysmgr.Add_TrackToPLaylist(PlaylistName.Text, username, int.Parse(e.CommandArgument.ToString()), song);


                    //rebind playlist
                    RefreshPlaylist(sysmgr, username);
                }, "great success", "added track to playlist");
            }
        }
 protected void TracksSelectionList_ItemCommand(object sender, ListViewCommandEventArgs e)
 {
     //code to go here
     if (string.IsNullOrEmpty(PlaylistName.Text))
     {
         //use the MessageUserControl method .ShowInf("title", "message")
         MessageUserControl.ShowInfo("Required data", "Play list name is required to add a track.");
     }
     else
     {
         //collect the needed data
         string playlistname = PlaylistName.Text;
         //string username = User.Identity.Name; //comes from security
         string username = "******";
         //obtain the TrackId from the ListView
         //CommandArgument is an object
         int trackid = int.Parse(e.CommandArgument.ToString());
         MessageUserControl.TryRun(() =>
         {
             PlaylistTracksController sysmgr = new PlaylistTracksController();
             sysmgr.Add_TrackToPLaylist(playlistname, username, trackid);
             List <UserPlaylistTrack> results = sysmgr.List_TracksForPlaylist(playlistname, username);
             PlayList.DataSource = results;
             PlayList.DataBind();
         }, "Adding a Track", "Track has been added to the playlist.");
     }
 }
Example #3
0
        protected void TracksSelectionList_ItemCommand(object sender,
                                                       ListViewCommandEventArgs e)
        {
            if (string.IsNullOrEmpty(PlaylistName.Text))
            {
                MessageUserControl.ShowInfo("Required data", "Play list name is required to add a track");
            }
            else
            {
                //collect the required data for the event
                string playlistname = PlaylistName.Text;
                //the username will come from the security
                //so untill security is added, we will use HansenB
                string username = User.Identity.Name;
                //obtain the track id from the ListView
                //the track id will be in the commandArg property of the ListViewCommandEventArgs e instance
                //the commandarg in e is return as an object
                int trackid = int.Parse(e.CommandArgument.ToString());

                MessageUserControl.TryRun(() =>
                {
                    PlaylistTracksController sysmgr = new PlaylistTracksController();
                    sysmgr.Add_TrackToPLaylist(playlistname, username, trackid);
                    List <UserPlaylistTrack> datainfo = sysmgr.List_TracksForPlaylist(playlistname, username);
                    PlayList.DataSource = datainfo;
                    PlayList.DataBind();
                }, "Adding a Track", "Track has been added to the playlist");
            }
        }
    protected void TracksSelectionList_ItemCommand(object sender,
                                                   ListViewCommandEventArgs e)
    {
        //code to go here
        if (string.IsNullOrEmpty(PlaylistName.Text))
        {
            //able to display a message to the user via the MessageUserControl
            //one of the methods of MessageUserControl is .ShowInfo()
            MessageUserControl.ShowInfo("Warning", "Playlist Name is required.");
        }
        else
        {
            string username = User.Identity.Name;

            //where does TrackId come from
            // ListViewCommandEcventargs e contains the parameter values for this event ; CommandArgument
            //CommandArgument is an object

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

            //send your collection of parameter values to the BLL for processing

            MessageUserControl.TryRun(() =>
            {
                //the process
                PlaylistTracksController sysmgr         = new PlaylistTracksController();
                List <UserPlaylistTrack> refreshResults = sysmgr.Add_TrackToPLaylist(PlaylistName.Text, username, trackid);
                PlayList.DataSource = refreshResults;
                PlayList.DataBind();
            }, "Success", "your track has been added to your playlist");
        }
    }
 protected void TracksSelectionList_ItemCommand(object sender,
                                                ListViewCommandEventArgs e)
 {
     //validate incoming parameters
     if (string.IsNullOrEmpty(PlaylistName.Text))
     {
         MessageUserControl.ShowInfo("Required Data ", "Adding a track requires a playlist name.");
     }
     else
     {
         string playlistName = PlaylistName.Text;
         //username eventually will come from security. Currently hardcoded
         string username = User.Identity.Name;
         //track id comes from the list view command arguments
         int trackID = int.Parse(e.CommandArgument.ToString()); //the command argument must be cast to a string, then parsed to an int.
         MessageUserControl.TryRun(() =>
         {
             PlaylistTracksController controller = new PlaylistTracksController();
             controller.Add_TrackToPLaylist(playlistName, username, trackID);                           //add data here - there can only be one call to the database
             List <UserPlaylistTrack> info = controller.List_TracksForPlaylist(playlistName, username); //read data back to user
             PlayList.DataSource           = info;
             PlayList.DataBind();
         }, "Added track", "Track has been added to playlist.");
     }
 }
 protected void TracksSelectionList_ItemCommand(object sender,
                                                ListViewCommandEventArgs e)
 {
     //code to go here
     if (string.IsNullOrEmpty(PlaylistName.Text))
     {
         MessageUserControl.ShowInfo("Required Data", "Playlist Name is required to add a track to a playlist");
     }
     else
     {
         string playlistname = PlaylistName.Text;
         string username     = User.Identity.Name; // change when security implemented
         //obtain track id from the ListView line that was selected
         //for the line I have created a CommandArgument
         //this value is available via the ListViewCommandEventArgs parameter e
         int trackid = int.Parse(e.CommandArgument.ToString());
         MessageUserControl.TryRun(() =>
         {
             PlaylistTracksController sysmgr = new PlaylistTracksController();
             sysmgr.Add_TrackToPLaylist(playlistname, username, trackid);
             List <UserPlaylistTrack> datainfo = sysmgr.List_TracksForPlaylist(playlistname, username);
             PlayList.DataSource = datainfo;
             PlayList.DataBind();
         }, "Adding a Track", "Track has been added to the playlist.");
     }
 }
Example #7
0
        protected void TracksSelectionList_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            //this method will only execute if the user has pressed the plus sign on a visible row from the display
            if (string.IsNullOrEmpty(PlaylistName.Text))
            {
                MessageUserControl.ShowInfo("Playlist Name", "You must supply a playlist name");
            }
            else
            {
                //via security, one can obtain the username
                string username     = "******";
                string playlistname = PlaylistName.Text;

                //the trackid is attached to each listview row via the CommandArgument parameter
                //access to the trackid is done via the ListViewCommandEventArgs e parameter
                //the e parameter is treated as an object
                //some e parameters need to be cast as strings
                int trackid = int.Parse(e.CommandArgument.ToString());
                //all required data can now be sent to the BLL for further processing
                //user friendly error handling
                MessageUserControl.TryRun(() =>
                {
                    //connect to BLL
                    PlaylistTracksController sysmgr = new PlaylistTracksController();
                    sysmgr.Add_TrackToPLaylist(playlistname, username, trackid);
                    //code to retrieve the up to date playlist and tracks for refreshing the playlist track list
                    List <UserPlaylistTrack> info = sysmgr.List_TracksForPlaylist(playlistname, username);
                    PlayList.DataSource           = info;
                    PlayList.DataBind();
                }, "Track Added", "The track has been added, check your list below");
            }
        }
    protected void TracksSelectionList_ItemCommand(object sender,
                                                   ListViewCommandEventArgs e)
    {
        //ListViewCommandEventArgs paramter e contains the CommandArg value (TrackID from button )
        if (string.IsNullOrEmpty(PlaylistName.Text))
        {
            MessageUserControl.ShowInfo("Warning", "Playlist Name is required");
        }
        else
        {
            string username = User.Identity.Name;
            //TrackID is going to come from e.CommandArgument
            //e.commandArgument is an object, therfore convert to string

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

            // the following code calls a BLL method to add to the database

            MessageUserControl.TryRun(() =>
            {
                PlaylistTracksController sysmgr         = new PlaylistTracksController();
                List <UserPlaylistTrack> refreshresults = sysmgr.Add_TrackToPLaylist(PlaylistName.Text, username, trackid);
                PlayList.DataSource = refreshresults;
                PlayList.DataBind();
            }, "Success", "track added to playlist");
        }
    }
        //this is different than a straight click. Notice the CommandEventArgs parameter.
        protected void TracksSelectionList_ItemCommand(object sender,
                                                       ListViewCommandEventArgs e)
        {
            //do we have the playlist name
            if (string.IsNullOrEmpty(PlaylistName.Text))
            {
                //if we don't...
                MessageUserControl.ShowInfo("Required Data", "You need a play list name to add a track.");
            }
            else
            {
                //collect the required data for the event
                string playlistname = PlaylistName.Text;
                //the user name will come from the form security, so instead we will just use a hardcoded string until we add the security
                //string username = "******";
                string username = User.Identity.Name;
                //obtain the track id from the ListView.
                //the track ID will be in the CommandArg property of the ListViewCommandEventArgs e instance
                int trackid = int.Parse(e.CommandArgument.ToString()); //<-- what comes back is actually an object, so we need to type cast this thing.
                                                                       //the Commandarg in e is returned as an object. Cast it to a string, then you can Parse the string.

                //using the obtained data, issue your  call to the BLL method, this work will be done within a TryRun
                MessageUserControl.TryRun(() =>
                {
                    PlaylistTracksController sysmgr = new PlaylistTracksController();
                    //there is ONLY one call to add the data to the database.
                    sysmgr.Add_TrackToPLaylist(playlistname, username, trackid);
                    //refresh the playlist, and we already have the method to do that, so we are borrowing from our playlist fetch
                    //the REFRESH of the playlist is a READ.
                    List <UserPlaylistTrack> datainfo = sysmgr.List_TracksForPlaylist(playlistname, username);
                    PlayList.DataSource = datainfo;
                    PlayList.DataBind();
                }, "Adding a Track", "Success! Track added to playlist!");
            }
        }
Example #10
0
    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());

            //contect to BLL controller
            //call required method
            //refresh the screen
            //do all this under the user friendly error handler
            MessageUserControl.TryRun(() =>
            {
                PlaylistTracksController sysmgr = new PlaylistTracksController();
                sysmgr.Add_TrackToPLaylist(playlistname, username, trackid);
                List <UserPlaylistTrack> results = sysmgr.List_TracksForPlaylist(playlistname, username);
                PlayList.DataSource = results;
                PlayList.DataBind();
            }, "Playlist Track Added", "You have successfully added a new track to your list.");
        }
    }
Example #11
0
    protected void TracksSelectionList_ItemCommand(object sender,
                                                   ListViewCommandEventArgs e)
    {
        //code to go here
        //ListViewCommandEventArgs paramenters e contains  the CommandArg value
        if (string.IsNullOrEmpty(PlaylistName.Text))
        {
            MessageUserControl.ShowInfo("Warning", "Playlist Name is required.");
        }
        else //If we had something
        {
            string username = User.Identity.Name; //Underneath the user class, find the identity, and then take out Name

            //Trackid is going to come from e.CommandArguement
            //e.CommandArguement is an object therefore convery to string

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


            //the following code calls a BLL method to add to the database
            MessageUserControl.TryRun(() =>
            {
                PlaylistTracksController sysmgr         = new PlaylistTracksController();
                List <UserPlaylistTrack> refreshresults = sysmgr.Add_TrackToPLaylist(PlaylistName.Text, username, trackid);
                PlayList.DataSource = refreshresults;
                PlayList.DataBind();
            }, "Sucess", "Track added tp play list");
        }
    }
Example #12
0
        protected void TracksSelectionList_ItemCommand(object sender,
                                                       ListViewCommandEventArgs e)
        {
            //string username = "******";
            string username = User.Identity.Name;

            //validation of incoming data
            if (string.IsNullOrEmpty(PlaylistName.Text))
            {
                MessageUserControl.ShowInfo("Missing data", "Enter the playlist name");
            }
            else
            {
                //Reminder: MessageUserControl will do the error handling
                MessageUserControl.TryRun(() => {
                    //coding block for your logic to be run under the error handling
                    //    control of MessageUserControl

                    //a trx add to the database
                    //connect to controller
                    PlaylistTracksController sysmgr = new PlaylistTracksController();
                    //issue the call to the controller method
                    sysmgr.Add_TrackToPLaylist(PlaylistName.Text, username,
                                               int.Parse(e.CommandArgument.ToString()));
                    //refresh the playlist
                    List <UserPlaylistTrack> info = sysmgr.List_TracksForPlaylist
                                                        (PlaylistName.Text, username);
                    PlayList.DataSource = info;
                    PlayList.DataBind();
                }, "Add track to Playlist", "Track has been added to the playlist");
            }
        }
Example #13
0
        protected void TracksSelectionList_ItemCommand(object sender,
                                                       ListViewCommandEventArgs e)
        {
            //code to go here
            //do we have thge playlist name?
            if (string.IsNullOrEmpty(PlaylistName.Text))
            {
                MessageUserControl.ShowInfo("Required Data", "Playlist name is required to add a track.");
            }
            else
            {
                //collect the required data for the event
                string playlistname = PlaylistName.Text;
                //the username will come from the form security
                //so until security is added, we will use HansenB
                string username = "******";
                //obtain the track idea from the listview
                //the track id will be in the CommandArg property of the ListViewCommandEventArgs e instance.
                int trackid = (int.Parse(e.CommandArgument.ToString()));

                //using the obtained data, issue your call to the BLL method.
                //this work will be done within a TryRun()
                MessageUserControl.TryRun(() => {
                    PlaylistTracksController sysmgr = new PlaylistTracksController();
                    sysmgr.Add_TrackToPLaylist(playlistname, username, trackid);
                    //refresh the playlist
                    List <UserPlaylistTrack> datainfo = sysmgr.List_TracksForPlaylist(
                        playlistname, username);
                    PlayList.DataSource = datainfo;
                    PlayList.DataBind();
                }, "Adding A Track", "Track has been added to the playlist");
            }
        }
        /// <summary>
        /// Executes on user intiated add track event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void TracksSelectionList_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            if (string.IsNullOrEmpty(PlaylistName.Text))
            {
                MessageUserControl.ShowInfo(
                    "Playlist Name",
                    "Playlist name is required when adding a track.");
            }
            else
            {
                string username = "******"; // (!) Find via security
                string playlist = PlaylistName.Text;

                // Note: TrackID is imbedded on each list row (with the CommandArgument parameter)
                int trackID = int.Parse(e.CommandArgument.ToString());

                // Send data to the BLL
                MessageUserControl.TryRun(() =>
                {
                    // BLL connection
                    PlaylistTracksController sysmgr = new PlaylistTracksController();
                    sysmgr.Add_TrackToPLaylist(playlist, username, trackID);

                    // Refresh playlist track listing
                    List <UserPlaylistTrack> Info = sysmgr.List_TracksForPlaylist(playlist, username);
                    PlayList.DataSource           = Info;
                    PlayList.DataBind();
                },
                                          "Track Added",
                                          "Track successfully added to your playlist!");
            }
        }
        protected void TracksSelectionList_ItemCommand(object sender,
                                                       ListViewCommandEventArgs e)
        {
            if (string.IsNullOrEmpty(PlaylistName.Text))
            {
                MessageUserControl.ShowInfo("Required data", "play list name is required to add a track");
            }
            else
            {
                string playlistname = PlaylistName.Text;

                string username = "******";
                int    trackid  = int.Parse(e.CommandArgument.ToString());

                MessageUserControl.TryRun(() =>
                {
                    PlaylistTracksController sysmgr = new PlaylistTracksController();
                    sysmgr.Add_TrackToPLaylist(playlistname, username, trackid);
                    List <UserPlaylistTrack> datainfo = sysmgr.List_TracksForPlaylist(playlistname, username);

                    PlayList.DataSource = datainfo;
                    PlayList.DataBind();
                }
                                          , "Adding a Track", "Track has been added to the playlist");
            }
        }
Example #16
0
        protected void TracksSelectionList_ItemCommand(object sender,
                                                       ListViewCommandEventArgs e)
        {
            string username = "******";

            if (string.IsNullOrEmpty(PlaylistName.Text))
            {
                MessageUserControl.ShowInfo("Missing Data", "Enter the playlist name");
            }
            else
            {
                //Your code does not need to have a try catch
                //the try catch is inbedded within MessageUserControl
                //the syntax for executing for MessageUserControl
                //  MessageUserControl.TryRun(() => { coding block}, "Success Title","Success message");
                MessageUserControl.TryRun(() =>
                {
                    PlaylistTracksController sysmgr = new PlaylistTracksController();
                    //e is the track id that is passed from the web page
                    sysmgr.Add_TrackToPLaylist(PlaylistName.Text, username, int.Parse(e.CommandArgument.ToString()));
                    List <UserPlaylistTrack> info = sysmgr.List_TracksForPlaylist(PlaylistName.Text, username);
                    PlayList.DataSource           = info;
                    PlayList.DataBind();
                }, "Add track to playlsit", "Track has been added to the playlist");
            }
        }
Example #17
0
 protected void TracksSelectionList_ItemCommand(object sender,
                                                ListViewCommandEventArgs e)
 {
     //ListViewCommandEventArgs parameter e contains the commandarg value (in this case TrackID)
     if (string.IsNullOrEmpty(PlaylistName.Text))
     {
         MessageUserControl.ShowInfo("", "bad end");
     }
     else
     {
         string username = User.Identity.Name;
         //track id is going to come from e.CommandArgument
         //e.comarg is Antlr object so needs to be a string
         int trackid = int.Parse(e.CommandArgument.ToString());
         //the following code calls a BLL method to add to the database
         MessageUserControl.TryRun(() =>
         {
             PlaylistTracksController sysmgr         = new PlaylistTracksController();
             List <UserPlaylistTrack> refreshresults = sysmgr.Add_TrackToPLaylist(PlaylistName.Text, username, trackid);
             PlayList.DataSource = refreshresults;
             PlayList.DataBind();
         }, "Sucess", "Added to Playlist"
                                   );
     }
 }
        protected void TracksSelectionList_ItemCommand(object sender,
                                                       ListViewCommandEventArgs e)
        {
            string username = "******";  //until security is implemented

            //form event validation: presence (do i have data?)
            if (string.IsNullOrEmpty(PlaylistName.Text))
            {
                MessageUserControl.ShowInfo("Missing Data", "Enter a playlist name");
            }
            else
            {
                //Reminder: MessageUserControl will do the error handling
                MessageUserControl.TryRun(() =>
                {
                    //logic for your coding block
                    PlaylistTracksController sysmgr = new PlaylistTracksController();
                    //access a specific field on the selected ListView row.
                    string song = (e.Item.FindControl("NameLabel") as Label).Text;

                    sysmgr.Add_TrackToPLaylist(PlaylistName.Text, username, int.Parse(e.CommandArgument.ToString()), song);

                    RefreshPlayList(sysmgr, username);
                }, "Add Track to Playlist", "Track has been added to the playlist.");
            }
        }
Example #19
0
 protected void TracksSelectionList_ItemCommand(object sender,
                                                ListViewCommandEventArgs e)
 {
     if (string.IsNullOrEmpty(PlaylistName.Text))
     {
         MessageUserControl.ShowInfo("Missing Data", "Enter a playlist name");
     }
     else
     {
         string username = "******";
         MessageUserControl.TryRun(() =>
         {
             int trackid = int.Parse(e.CommandArgument.ToString());
             PlaylistTracksController sysmgr = new PlaylistTracksController();
             sysmgr.Add_TrackToPLaylist(PlaylistName.Text, username, trackid);
             List <UserPlaylistTrack> info = sysmgr.List_TracksForPlaylist(PlaylistName.Text, username);
             PlayList.DataSource           = info;
             PlayList.DataBind();
         }, "Add Track", "Track has been added to your playlist");
     }
 }
        protected void TracksSelectionList_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            //do we have the playlist name
            if (string.IsNullOrEmpty(PlaylistName.Text))
            {
                MessageUserControl.ShowInfo("Required Data", "PlayList Name Is Required To Add A Track");
            }
            else
            {
                // collect the required data for the event
                string playlistname = PlaylistName.Text;

                // the username will come from the form security
                //  so until security is added we will use HansenB
                string username = User.Identity.Name;

                // obtain the trackid from the ListView
                //  the trackid will be in the CommandArg property of the
                //  ListViewCommandEventArgs e instance
                // the CommandArgument in e is returned as an object
                //  case it to string, then you can .Parse the string
                int trackid = int.Parse(e.CommandArgument.ToString());

                // using the obtained data, issue your call to the BLL method
                // this work will be done within TryRun()
                MessageUserControl.TryRun(() =>
                {
                    PlaylistTracksController sysmgr = new PlaylistTracksController();

                    // There is ONLY one call to add the data to the database
                    sysmgr.Add_TrackToPLaylist(playlistname, username, trackid);

                    // refresh the playlist which is a READ
                    List <UserPlaylistTrack> datainfo = sysmgr.List_TracksForPlaylist(playlistname, username);

                    PlayList.DataSource = datainfo;
                    PlayList.DataBind();
                }, "Adding A Track", "Track Has Been Added To The PlayList");
            }
        }
Example #21
0
        protected void TracksSelectionList_ItemCommand(object sender,
                                                       ListViewCommandEventArgs e)
        {
            string username = "******";

            //Validate playlist exists
            if (string.IsNullOrEmpty(PlaylistName.Text))
            {
                MessageUserControl.ShowInfo("Missing Data", "Enter a playlist name.");
            }

            else
            {
                //Reminder: MessageUserControl will do the error handling
                MessageUserControl.TryRun(() =>
                {
                    PlaylistTracksController sysmgr = new PlaylistTracksController();
                    sysmgr.Add_TrackToPLaylist(PlaylistName.Text, username, int.Parse(e.CommandArgument.ToString()));
                    RefreshPlaylist(sysmgr, username);
                }, "Add track to playlist", "Track has been added to the playlist.");
            }
        }
        protected void TracksSelectionList_ItemCommand(object sender,
                                                       ListViewCommandEventArgs e)
        {
            //do we have the playlist name?
            if (string.IsNullOrEmpty(PlaylistName.Text))
            {
                messageUserControl.ShowInfo("Required data", "Playlist name is required to add a track");
            }
            else
            {
                //collect the required data for the event
                string playlistname = PlaylistName.Text;
                //the user name will come from the security form, which we don't have at this point.
                //we will use a hard coded string instead for HansenB
                string username = User.Identity.Name;
                //obtain the track id from the ListView
                //the track id will be in the commandArg property of the
                // ListViewCommandEventArgs e instance
                //the commandarg in e is returned as an object and
                //needs to be cast as a string in order to parse it as an int.
                int trackid = int.Parse(e.CommandArgument.ToString());

                //using the obtained data, issue your call to the BLL method.
                //this work will be done within a TryRun() as we need some error handling
                messageUserControl.TryRun(() =>
                {
                    PlaylistTracksController sysmgr = new PlaylistTracksController();
                    //there is only one call to add the data to the database
                    sysmgr.Add_TrackToPLaylist(playlistname, username, trackid);
                    //refresh the playlist is a READ only.
                    List <UserPlaylistTrack> datainfo = sysmgr.List_TracksForPlaylist(playlistname, username);
                    PlayList.DataSource = datainfo;
                    PlayList.DataBind();
                }, "Adding a Track", "Track has been added to the playlist");
            }
        }
    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;
            //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
            int trackid = int.Parse(e.CommandArgument.ToString());

            //contect to BLL controller
            //call required method
            //refresh the screen
            //do all this under the user friendly error handler
            MessageUserControl.TryRun(() =>
            {
                PlaylistTracksController sysmgr = new PlaylistTracksController();
                sysmgr.Add_TrackToPLaylist(playlistname, username, trackid);
                List <UserPlaylistTrack> results = sysmgr.List_TracksForPlaylist(playlistname, username);
                PlayList.DataSource = results;
                PlayList.DataBind();
            }, "Playlist Track Added", "You have successfully added a new track to your list.");
        }
    }
        protected void TracksSelectionList_ItemCommand(object sender,
                                                       ListViewCommandEventArgs e)
        {
            //Do we have the playlist name
            if (string.IsNullOrEmpty(PlaylistName.Text))
            {
                MessageUserControl.ShowInfo("Required Data", "PlayList Name is Required to ADD a Track");
            }
            else
            {
                //Collect the required data for the event
                string playlistname = PlaylistName.Text;
                //The user name will come from the form security
                //so until security is added, we will use HanseB
                string username = "******";
                //Obtain the TrackId from the listView
                //the TrackId will be in the CommandArg property of the ListViewCommandEventArg e instance
                //The CommandArg in e is returned as an object
                //case it to a string, then you can .Parse the string
                int trackid = int.Parse(e.CommandArgument.ToString());

                //Using the obtained data, issue your call to the BLL Method
                //This work will be done whinin a TryRun()
                MessageUserControl.TryRun(() =>
                {
                    PlaylistTracksController sysmgr = new PlaylistTracksController();
                    //there is only one call to add the data to the database
                    sysmgr.Add_TrackToPLaylist(playlistname, username, trackid);

                    //Refresh the PlayList is a READ
                    List <UserPlaylistTrack> datainfo = sysmgr.List_TracksForPlaylist(playlistname, username);
                    PlayList.DataSource = datainfo;
                    PlayList.DataBind();
                }, "Adding a Track", "Track Has been added to the Play List");
            }
        }