// GET: Playlists/Edit/5
        public ActionResult Edit(int? id)
        {
            // Study the Edit view

            // Attempt to fetch the matching object
            var o = m.PlaylistGetByIdWithDetails(id.GetValueOrDefault());

            if (o == null)
            {
                return HttpNotFound();
            }
            else
            {
                // Create a form
                var form = new PlaylistEditTracksForm();

                // Configure its properties
                // Alternatively, could create a mapper etc.
                form.PlaylistId = o.PlaylistId;
                form.Name = o.Name;
                form.TracksNowOnPlaylist = o.Tracks.OrderBy(t => t.Name);

                // Attention - 2 - Modified form-building strategy in the controller...
                // Need some data to enable a customized view
                // Look in the view...
                // Build a checkbox group, of genres, with the onchange event handled
                // Build a track list, with "display: none" to initially hide the rows
                // Turn them on as each genre is checked/selected

                // Call the method to get all tracks, with genre name
                form.TrackList = m.TrackWithGenreGetAll();

                // Now, go through the tracks-now-on-the-playlist,
                // and set the "selected" property
                foreach (var item in form.TracksNowOnPlaylist)
                {
                    form.TrackList.SingleOrDefault(t => t.TrackId == item.TrackId).Selected = true;
                }

                // Get the genre list, to display in the UI
                form.GenreList = m.GenreGetAll();

                return View(form);
            }
        }
        // GET: Playlists/Edit/5
        public ActionResult Edit(int?id)
        {
            // Study the Edit view

            // Attempt to fetch the matching object
            var o = m.PlaylistGetByIdWithDetails(id.GetValueOrDefault());

            if (o == null)
            {
                return(HttpNotFound());
            }
            else
            {
                // Create a form
                var form = new PlaylistEditTracksForm();

                // Configure its properties
                // Alternatively, could create a mapper etc.
                form.PlaylistId          = o.PlaylistId;
                form.Name                = o.Name;
                form.TracksNowOnPlaylist = o.Tracks.OrderBy(t => t.Name);

                // Attention - 2 - Modified form-building strategy in the controller...
                // Need some data to enable a customized view
                // Look in the view...
                // Build a checkbox group, of genres, with the onchange event handled
                // Build a track list, with "display: none" to initially hide the rows
                // Turn them on as each genre is checked/selected

                // Call the method to get all tracks, with genre name
                form.TrackList = m.TrackWithGenreGetAll();

                // Now, go through the tracks-now-on-the-playlist,
                // and set the "selected" property
                foreach (var item in form.TracksNowOnPlaylist)
                {
                    form.TrackList.SingleOrDefault(t => t.TrackId == item.TrackId).Selected = true;
                }

                // Get the genre list, to display in the UI
                form.GenreList = m.GenreGetAll();

                return(View(form));
            }
        }