public async Task <PlayerSongDto> GetNextSong(NextSongDto nextSongRequest)
        {
            MusicService service = new MusicService();
            var          song    = service.GetNextSong(nextSongRequest, User.Identity.Name);

            return(song);
        }
Beispiel #2
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);
            }
        }
Beispiel #3
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);
        }