private static Song GetNextSong(NextSongDto songRequest, string username, SmartPlayerEntities context) { MusicRepository musicRepo = new MusicRepository(context); var excludedSongIdList = songRequest.PlayedSongIds; var recommendedSongs = GetRecommendedSongsForUser(username, context); recommendedSongs = recommendedSongs.Where(x => !excludedSongIdList.Contains(x.Id)).ToList(); var similarSongs = musicRepo.GetNextSongBasedOnUserAndGrade(songRequest.CurrentSongId); similarSongs = similarSongs.Where(x => !excludedSongIdList.Contains(x.Id)).ToList(); var safetySet = new Lazy <List <Song> >(() => musicRepo.GetNextSongBasedOnUserAndGrade(songRequest.CurrentSongId, excludedSongIdList)); var selectedSong = GetNextSong(recommendedSongs, similarSongs, safetySet); return(selectedSong); }
private static Song GetNextSong(NextSongDto songRequest, string username, SmartPlayerEntities context) { MusicRepository musicRepo = new MusicRepository(context); var excludedSongIdList = songRequest.PlayedSongIds; var recommendedSongs = GetRecommendedSongsForUser(username, context); recommendedSongs = recommendedSongs.Where(x => !excludedSongIdList.Contains(x.Id)).ToList(); var similarSongs = musicRepo.GetNextSongBasedOnUserAndGrade(songRequest.CurrentSongId); similarSongs = similarSongs.Where(x => !excludedSongIdList.Contains(x.Id)).ToList(); var safetySet = new Lazy<List<Song>>(() => musicRepo.GetNextSongBasedOnUserAndGrade(songRequest.CurrentSongId, excludedSongIdList)); var selectedSong = GetNextSong(recommendedSongs, similarSongs, safetySet); return selectedSong; }