//_______________________________________________________________________________// private List <SelectListItem> getSelectlistAvailableTracksInAlbum(int?albumId) { List <Track_Album> track_albums = T_aDB.GetAllTracksFromAlbum((int)albumId); IEnumerable <int> trackIDs = track_albums.Select(t_a => t_a.TrackId); IEnumerable <Track> AllTracks; using (TrackRepository TrackDB = new TrackRepository()) { AllTracks = TrackDB.GetAll().Where(t => !trackIDs.Contains(t.Id)); } return(AllTracks.Select(t => new SelectListItem { Text = t.name, Value = t.Id.ToString() }).ToList()); }
// GET: Album/Tracks/5 public ActionResult Tracks(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Album album = AlbumDB.Find(id); if (album == null) { return(HttpNotFound()); } List <Track_Album> track_albums = T_aDB.GetAllTracksFromAlbum((int)id); IEnumerable <int> trackIDs = track_albums.Select(t_a => t_a.TrackId); IEnumerable <Track> AllTracks; using (TrackRepository TrackDB = new TrackRepository()) { AllTracks = TrackDB.GetAll().Where(t => !trackIDs.Contains(t.Id)); } ViewBag.TrackAlbumSelectList = AllTracks.Select(t => new SelectListItem { Text = t.name, Value = t.Id.ToString() }).ToList(); return(View(new Track_AlbumCreateList() { track_album = new Track_Album(), ExistingTrack_Albums = track_albums })); }