예제 #1
0
        public PlayerSongDto GetNextSong(NextSongDto songRequest, string username = null)
        {
            using (SmartPlayerEntities context = new SmartPlayerEntities())
            {
                var selectedSong = GetNextSong(songRequest, username, context);
                var songUrl = ExtractSongUrl(selectedSong);

                PlayerSongDto song = ExtractSongResult(username, context, selectedSong, songUrl);

                return song;
            }
        }
예제 #2
0
        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;
        }
 public async Task<PlayerSongDto> GetNextSong(NextSongDto nextSongRequest)
 {
     MusicService service = new MusicService();
     var song = service.GetNextSong(nextSongRequest, User.Identity.Name);
     return song;
 }