Esempio n. 1
0
        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 requied 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 = "******";
                string username = User.Identity.Name;
                //obtain the track id from the ListView
                //the trackid will be in the CommandArgproperty of the
                //ListViewCommandEventArgs e instance
                //the CommandArg is e is return as an object
                //cast it to a string, then you can .Parse the string
                int trackid = int.Parse(e.CommandArgument.ToString());


                //using the obtrained data, issue your call to the BLL method
                //this work will be done with 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();
                }, "Addinga Track", "Track has been added to the playlist");
            }
            //code to go here
        }