public bool AddToOnboardingSongs(string playlistId, OnBoardingSong onBoardingSong) { bool songAdded = false; IPlaylist playlist = GetPlaylistById(playlistId); if (playlist != null) { songAdded = playlist.AddToOnboardingSongs(onBoardingSong); } return(songAdded); }
private OnBoardingSong GetHighestVotedSong(List <OnBoardingSong> onBoardingSongs) { // update currently just first OnBoardingSong highestVotedSong = null; if (onBoardingSongs != null && onBoardingSongs.Count > 0) { // should make onboardingsongs a priority queue highestVotedSong = onBoardingSongs.OrderByDescending(x => x.GetAverageRating()).ToList()[0]; } return(highestVotedSong); }
public bool AddToOnboardingSongs(OnBoardingSong onBoardingSong) { bool songAdded = false; // probably should've used some sort of ordered set if (null == onBoardingSongs.Find(x => (x.song.name == onBoardingSong.song.name && x.song.artist == onBoardingSong.song.artist))) { onBoardingSongs.Add(onBoardingSong); AddTrackToPlaylist(); songAdded = true; } return(songAdded); }
private OnBoardingSong SelectNextSong() { OnBoardingSong nextSong = onBoardingSongs.Find(x => x.priority == true); if (nextSong == null) { nextSong = GetHighestVotedSong(onBoardingSongs); if (nextSong != null) { nextSong.submitter.SongSelected(); } } if (nextSong != null) { onBoardingSongs.Remove(nextSong); } return(nextSong); }
public bool UpdateTrackVote(User user, string trackUri, int rating) { bool trackUpdated = false; OnBoardingSong track = onBoardingSongs.Find(x => x.song.trackUri == trackUri); if (track != null && user != null) { // username is unique id Vote vote = track.votes.Find(x => x.user.name == user.name); if (vote == null) { vote = new Vote(); vote.user = user; track.votes.Add(vote); vote.score = rating; trackUpdated = true; } } return(trackUpdated); }