public SelectedDataText DoSomething(UserSelectedData newItem)
{
var o = new SelectedDataText();
// Artist
var artist = ds.Artists.Find(newItem.ArtistId);
o.ArtistName = (artist == null) ? "(not found)" : artist.Name;
// Album
var album = ds.Albums
.Include("Tracks")
.SingleOrDefault(a => a.AlbumId == newItem.AlbumId);
o.AlbumTitle = (album == null) ? "(not found)" : album.Title;
// Tracks
if (album == null)
{
o.TrackNames.Add("(not found)");
}
else
{
// Get the track names for the selected tracks
foreach (var item in album.Tracks)
{
if (newItem.TrackIds.Contains(item.TrackId))
{
o.TrackNames.Add(item.Name);
}
}
}
return o;
}