// GET: Playlist/Edit/5
public ActionResult Edit(int?id)
{
// Attempt to fetch the matching object
var o = m.PlaylistGetByIdWithDetail(id.GetValueOrDefault());
if (o == null)
{
return(HttpNotFound());
}
else
{
// Create a form, based on the fetched matching object
var form = Mapper.Map <PlaylistBase, PlaylistEditTracksForm>(o);
// For the multi select list, configure the "selected" items
var selectedValues = o.Tracks.Select(jd => jd.TrackId);
form.TracksPlaying = o.Tracks.OrderBy(e => e.Name);
form.TracksList = new MultiSelectList
(items: m.TrackGetAll(),
dataValueField: "TrackId",
dataTextField: "FullName",
selectedValues: selectedValues);
return(View(form));
}
}