public ViewResult GetPlaylist(int id) { //var info = HttpContext.Session.GetString("SessionUser"); //if (info != null) //{ // var result = JsonConvert.DeserializeObject<UserInfo>(info); //} //PlayList playList = _playlists.GetPlaylist(id); var plTrecks = _playlistsTreck.GetPlaylistTrecksbyPlayList(id); IEnumerable <Treck> treks = _trecks.GetTrecks; string treksGenre = ""; foreach (var pltreck in plTrecks) { if (pltreck.PlayListId != id) { treks = treks.Where(x => x.Id == pltreck.TreckId); } treks = treks.Where(x => x.Id != pltreck.TreckId); } var treckObj = new TreckListViewModel { GetTrecks = _trecks.GetTrecks.Except(treks), TreckGenre = treksGenre }; return(View(treckObj)); }
public ViewResult ListTreks(string category) { //var info = HttpContext.Session.GetString("SessionUser"); //if (info != null) //{ // var result = JsonConvert.DeserializeObject<UserInfo>(info); //} IEnumerable <Treck> treks = null; string treksGenre = ""; if (string.IsNullOrEmpty(category)) { treks = _trecks.GetTrecks.OrderBy(t => t.Id); } else { treks = _trecks.GetTrecks .Where(x => x.Genre.GenreName.ToLower() == category.ToLower()); treksGenre = category; } var treckObj = new TreckListViewModel { GetTrecks = treks, TreckGenre = treksGenre }; return(View(treckObj)); }