コード例 #1
0
        protected void PlayListFetch_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(PlaylistName.Text))
            {
                MessageUserControl.ShowInfo("Missing Data", "Please Enter the playlist name");
            }
            else
            {
                string username = "******"; //Username will come from security once implemented

                //MessageUserControl will be used to handle the code behind user friendly error handling
                //you will NOT be using try/catch
                //your try/catch is embedded within the MessageUserControl class
                MessageUserControl.TryRun(() =>
                {
                    PlaylistTracksController sysmgr       = new PlaylistTracksController();
                    List <UserPlaylistTrack> playlistInfo = null;
                    playlistInfo = sysmgr.List_TracksForPlaylist(PlaylistName.Text, username);
                    if (playlistInfo == null)
                    {
                        throw new Exception("Playlist no longer exists");
                    }
                    else
                    {
                        PlayList.DataSource = playlistInfo;
                        PlayList.DataBind();
                    }
                }, "Playlist", "Manage your playlist");//string after successful coding block
            }
        }
コード例 #2
0
    protected void PlayListFetch_Click(object sender, EventArgs e)
    {
        //standard query
        if (string.IsNullOrEmpty(PlaylistName.Text))
        {
            //put out error message
            //this form uses a user control called MessageUserControl
            MessageUserControl.ShowInfo("Warning", "Playlist Name is required");
        }
        else
        {
            //MessageUserControl has Try Catch coding embedded in the control
            MessageUserControl.TryRun(() =>
            {
                //this is the process coding block to be executed under the "watchful eye" of the MessageUSerControl

                //obtain the username from the security part of the application
                string username = User.Identity.Name;
                PlaylistTracksController sysmgr = new PlaylistTracksController();
                List <UserPlaylistTrack> info   = sysmgr.List_TracksForPlaylist(PlaylistName.Text, username);
                PlayList.DataSource             = info;
                PlayList.DataBind();
            }, "", "Here is your current playlist");
        }
    }
コード例 #3
0
 protected void PlayListFetch_Click(object sender, EventArgs e)
 {
     //code to go here
     if (string.IsNullOrEmpty(PlaylistName.Text))
     {
         /* use the MessageUserControl method .ShowInfo("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 = User.Identity.Name; // "HansenB";
         MessageUserControl.TryRun(() =>
         {
             PlaylistTracksController sysmgr  = new PlaylistTracksController();
             List <UserPlaylistTrack> results = sysmgr.List_TracksForPlaylist(
                 playlistname, username);
             PlayList.DataSource = results;
             PlayList.DataBind();
         }, "Playlist Tracks", "See current tracks on playlist below.");
     }
 }
コード例 #4
0
 protected void PlayListFetch_Click(object sender, EventArgs e)
 {
     //code to go here
     //standard query implementation
     if (string.IsNullOrEmpty(PlaylistName.Text))
     {
         //throw error message
         //use usercontrolmessage. MessageUserControl
         MessageUserControl.ShowInfo("Warning...", "Playlist Name is required...");
         //the user control will be the mechanism to display messages on this form
     }
     else
     {
         //no need for try catches, the MEssageUserControl has the trycatch coding built inside it
         //
         MessageUserControl.TryRun(() =>
         {
             //this is the process coding block to be executed under the "watchful eye" of the MUC
             //
             //obtain username from the security part of the application
             string username = User.Identity.Name;
             PlaylistTracksController sysmgr   = new PlaylistTracksController();
             List <UserPlaylistTrack> playlist = sysmgr.List_TracksForPlaylist(PlaylistName.Text, username);
             PlayList.DataSource = playlist;
             PlayList.DataBind();
         }, "", "Here is your current playlist");
     }
 }
コード例 #5
0
        //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!");
            }
        }
コード例 #6
0
    protected void PlayListFetch_Click(object sender, EventArgs e)
    {
        //code to go here
        //standard query
        if (string.IsNullOrEmpty(PlaylistName.Text))
        {
            //put out an error message
            //this form uses a user control called MessageUserControl
            //the user control will be the mechanism to display messages on this form
            MessageUserControl.ShowInfo("Warning", "Playlist name is required");
        }
        else
        {
            //MessageUserControl already has the try/catch cosing embedded in the control
            MessageUserControl.TryRun(() =>

            {
                //this is the process coding block to be executed under the
                //"watchful eye" of the MessageUser control

                //obtain the user name from the security part of the application
                string username = User.Identity.Name;
                PlaylistTracksController sysmgr   = new PlaylistTracksController();
                List <UserPlaylistTrack> playlist = sysmgr.List_TracksForPlaylist
                                                        (PlaylistName.Text, username);
                PlayList.DataSource = playlist;
                PlayList.DataBind();
            }, "//title", "here is yout current plalist.");
        }
    }
コード例 #7
0
 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.");
     }
 }
コード例 #8
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.");
        }
    }
コード例 #9
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");
            }
        }
コード例 #10
0
 protected void MoveTrack(int trackid, int tracknumber, string direction)
 {
     MessageUserControl.TryRun(() => {
         PlaylistTracksController sysmgr = new PlaylistTracksController();
         sysmgr.MoveTrack("HansenB", PlaylistName.Text, trackid, tracknumber, direction);
     }, "Success", "Track has been moved");
 }
コード例 #11
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");
            }
        }
コード例 #12
0
        /// <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!");
            }
        }
コード例 #13
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
            {
                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");
            }
        }
コード例 #14
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");
            }
        }
コード例 #15
0
 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.");
     }
 }
コード例 #16
0
        protected void PlayListFetch_Click(object sender, EventArgs e)
        {
            //username is coming from the system via security
            //since security has yet to be installed, a defualt will be setup for the
            //   username value
            //string username = "******";

            //now that security is inplace we will use the User instance of get the user name
            string username = User.Identity.Name;

            if (string.IsNullOrEmpty(PlaylistName.Text))
            {
                MessageUserControl.ShowInfo("Playlist Search", "No playlist name was supplied.");
            }
            else
            {
                //use some user friendly error handling
                //the way we are doing the error handling is using MessageUserControl instead
                //  of try/catch
                //MessageUserControl has the try/catch embedded within the control logic
                //within the MessageUserControl there exists a method called .TryRun()
                //syntax
                //   MessageUserControl.TryRun( () => {
                //
                //     your coding logic
                //
                //  }[,"message title","success message"]);
                //
                MessageUserControl.TryRun(() => {
                    PlaylistTracksController sysmgr = new PlaylistTracksController();
                    RefreshPlayList(sysmgr, username);
                }, "Playlist Search", "View the requested playlist below");
            }
        }
コード例 #17
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");
            }
        }
コード例 #18
0
 protected void PlayListFetch_Click(object sender, EventArgs e)
 {
     //code to go here
     if (string.IsNullOrEmpty(PlaylistName.Text))
     {
         MessageUserControl.ShowInfo("Required Data",
                                     "Playlist Name is required to retreive tracks.");
     }
     else
     {
         string username     = "******";
         string playlistname = PlaylistName.Text;
         MessageUserControl.TryRun(() => {
             PlaylistTracksController sysmgr  = new PlaylistTracksController();
             List <UserPlaylistTrack> results =
                 sysmgr.List_TracksForPlaylist(playlistname, username);
             if (results.Count() == 0)
             {
                 MessageUserControl.ShowInfo("Check playlist name");
             }
             PlayList.DataSource = results;
             PlayList.DataBind();
         });
     }
 }
コード例 #19
0
        protected void PlayListFetch_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(PlaylistName.Text))
            {
                MessageUserControl.ShowInfo("Required Data",
                                            "Play list name is required to fetch a play list");
            }
            else
            {
                string playlistname = PlaylistName.Text;
                //until we do security, we will use a hard coded username
                //string username = "******";

                //Once security is Implemented you can obtain the
                //User name from User.Identity Class Property .Name
                string username = User.Identity.Name;
                //do a standard query lookup to your control
                //use MessageUserControl for error handling
                MessageUserControl.TryRun(() =>
                {
                    PlaylistTracksController sysmgr   = new PlaylistTracksController();
                    List <UserPlaylistTrack> datainfo = sysmgr.List_TracksForPlaylist(
                        playlistname, username);
                    PlayList.DataSource = datainfo;
                    PlayList.DataBind();
                }, "Playlist Tracks", "See current tracks on playlist below");
            }
        }
コード例 #20
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");
            }
        }
コード例 #21
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"
                                   );
     }
 }
コード例 #22
0
        protected void PlayListFetch_Click(object sender, EventArgs e)
        {
            //security is yet to be implemented
            //this page needs to known the username of the currently logged user
            //temporarily we will hard core the username
            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 embedded within MessageUserControl
                //The syntax for executing with MessageUserControl
                //   MessageUserControl.TryRun(() => { coding block},"Success Title","Success message");
                MessageUserControl.TryRun(() =>
                {
                    PlaylistTracksController sysmgr = new PlaylistTracksController();
                    List <UserPlaylistTrack> info   = sysmgr.List_TracksForPlaylist(PlaylistName.Text, username);
                    PlayList.DataSource             = info;
                    PlayList.DataBind();
                }, "Playlist", "View current songs on playlist");
            }
        }
コード例 #23
0
 protected void PlayListFetch_Click(object sender, EventArgs e)
 {
     //verify if the data is there
     if (string.IsNullOrEmpty(PlaylistName.Text))
     {
         MessageUserControl.ShowInfo("Required Data", "Play list name is required.");
     }
     else
     {
         //call BLL
         string playlistname = PlaylistName.Text;
         //until we do security, we will use a hard coded username
         //string username = "******"; once, security is implemented, you can obtain the user name from user.identity class property .name
         string username = User.Identity.Name;
         //do a standard query lookup to your controller, use MessageUserControl for error handling
         MessageUserControl.TryRun(() =>
         {
             PlaylistTracksController sysmgr   = new PlaylistTracksController();
             List <UserPlaylistTrack> datainfo = sysmgr.List_TracksForPlaylist(playlistname, username);
             PlayList.DataSource = datainfo; //if nothing is coming back it will show the template
             PlayList.DataBind();
         }, "Playlist Tracks", "See current tracks on playlist below"
                                   );
     }
 }
コード例 #24
0
        protected void RefreshPlayList(PlaylistTracksController sysmgr, string username)
        {
            List <UserPlaylistTrack> info = sysmgr.List_TracksForPlaylist(PlaylistName.Text, username);

            PlayList.DataSource = info;
            PlayList.DataBind();
        }
コード例 #25
0
    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");
        }
    }
コード例 #26
0
        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.");
            }
        }
コード例 #27
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");
            }
        }
コード例 #28
0
        protected void PlayListFetch_Click(object sender, EventArgs e)
        {
            //username is coming from the system via security
            //since security has yet to be installed, a default will be setup for the
            //  username value
            string username = "******";

            if (string.IsNullOrEmpty(PlaylistName.Text))
            {
                MessageUserControl.ShowInfo("Playlist Search", "No playlist name was supplied.");
            }
            else
            {
                //use some user friendly error handling
                //the way we are doing the error handling is using MessageUserControl instead of
                //  try/catch.
                //MessageUserControl has the try/catch embedded within the control logic.
                //Within in the MessageUserControl, there exists a method called ".TryRun()"
                //syntax
                //  MessageUserControl.TryRun( () => {
                //
                //      your coding logic
                //
                //   }[,"Message Title","Success Message"]);    ( [] = optional  )
                MessageUserControl.TryRun(() =>
                {
                    PlaylistTracksController sysmgr = new PlaylistTracksController();
                    RefreshPlayList(sysmgr, username);
                }, "Playlist Search", "View the requested playlist below.");
            }
        }
コード例 #29
0
 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.");
     }
 }
コード例 #30
0
        protected void PlayListFetch_Click(object sender, EventArgs e)
        {
            //username is coming from the system via security
            //since security has yet to be installed, a default will be setup for the
            //    username value
            string username = "******";

            if (string.IsNullOrEmpty(PlaylistName.Text))
            {
                MessageUserControl.ShowInfo("Playlist Search", "No palylist name was supplied");
            }
            else
            {
                //use some user friendly error handling
                //the way we are doing the error is using MessageUserControl instead of
                //     using try/catch
                //MessageUserControl has the try/catch embedded within the control
                //within the MessageUserControl there exists a method called .TryRun()
                //syntax
                //    MessageUserControl.TryRun(() =>{
                //
                //      coding block
                //
                //    }[,"message title","success message"]);
                MessageUserControl.TryRun(() =>
                {
                    //code to execute under error handling control of MessageUserControl
                    PlaylistTracksController sysmgr = new PlaylistTracksController();
                    List <UserPlaylistTrack> info   = sysmgr.List_TracksForPlaylist(PlaylistName.Text, username);
                    PlayList.DataSource             = info;
                    PlayList.DataBind();
                }, "Playlist Search", "View the requested playlist below.");
            }
        }