Exemple #1
0
        public async Task TogglePlaybackAsync(PartyGoer partyGoer)
        {
            // Grabbing partier by reference, so any change I make to it will change it in the list
            PartyGoer partier = Listeners.Find(p => p.Equals(partyGoer));

            partier.PausedMusic = !partier.PausedMusic;

            await DomainEvents.RaiseAsync(new ToggleMusicState { Listener = partier, State = DetermineMusicState(partier.PausedMusic) });
        }
Exemple #2
0
        public bool DoesUserLikeTrack(PartyGoer partyGoer, string trackUri)
        {
            if (_usersLikedTracks.ContainsKey(partyGoer.GetId()))
            {
                return(_usersLikedTracks[partyGoer.GetId()].Contains(trackUri));
            }

            return(false);
        }
Exemple #3
0
 public Party(PartyGoer host)
 {
     Id        = Guid.NewGuid();
     Host      = host;
     Listeners = new List <PartyGoer>()
     {
         host
     };
     PartyCode = GeneratePartyCode();
 }
Exemple #4
0
        public async Task UserRequestedSkipAsync(PartyGoer partyGoer)
        {
            UsersThatRequestedSkip.Add(partyGoer);

            if (UsersThatRequestedSkip.Count > _listeners.Count * 0.5)
            {
                // Skip the song
                await NextSongAsync();

                UsersThatRequestedSkip.Clear();
            }
        }
Exemple #5
0
        public async Task UserLikesTrackAsync(PartyGoer user, string trackUri, string partyCode)
        {
            if (!_usersLikesDislikes.DoesUserLikeTrack(user, trackUri))
            {
                _usersLikesDislikes.UserLikesTrack(user, trackUri);

                TrackWithFeelings track = _tracks.Find(p => p.GetTrackWithoutFeelings().Id.Equals(trackUri, StringComparison.OrdinalIgnoreCase));

                if (track != null)
                {
                    track.UserLikesTrack();
                    _tracks.Sort(new ReorderQueueComparer());

                    await DomainEvents.RaiseAsync(new UpdateQueue { Tracks = _tracks.Select(p => p.GetTrackWithoutFeelings()).ToList(), PartyCode = partyCode });
                }
            }
        }
Exemple #6
0
 public LikesDislikes GetUsersTrackFeelings(PartyGoer user)
 {
     return(_usersLikesDislikes.GetUsersTrackFeelings(user));
 }
Exemple #7
0
 public void JoinParty(PartyGoer partyGoer)
 {
     Listeners.Add(partyGoer);
 }
Exemple #8
0
 public void RemoveListener(PartyGoer listener)
 {
     _listeners.RemoveAll(p => p.Id.Equals(listener.Id, StringComparison.OrdinalIgnoreCase));
 }
Exemple #9
0
 private void StoreUsersLikedTrack(PartyGoer user, string trackUri)
 {
     _sumOfLikes.AdjustTrackFeelings(trackUri, Feelings.Like);
     _usersLikedTracks.AddFeelings(user, trackUri);
     _usersDislikedTracks.RemoveFeelings(user, trackUri);
 }
Exemple #10
0
 public void UserLikesTrack(PartyGoer user, string trackUri)
 {
     StoreUsersLikedTrack(user, trackUri);
 }
Exemple #11
0
 public LikesDislikes GetUsersTrackFeelings(PartyGoer user)
 {
     return(new LikesDislikes(_usersLikedTracks.GetUsersTracks(user), _usersDislikedTracks.GetUsersTracks(user)));
 }
Exemple #12
0
 public static List <string> GetUsersTracks(this Dictionary <string, List <string> > dictionary, PartyGoer partyGoer)
 {
     if (dictionary.ContainsKey(partyGoer.GetId()))
     {
         return(dictionary[partyGoer.GetId()]);
     }
     else
     {
         return(new List <string>());
     }
 }
Exemple #13
0
 public static void RemoveFeelings(this Dictionary <string, List <string> > dictionary, PartyGoer partyGoer, string trackUri)
 {
     if (dictionary.ContainsKey(partyGoer.GetId()))
     {
         dictionary[partyGoer.GetId()].RemoveAll(p => p.Equals(trackUri));
     }
 }
Exemple #14
0
 public static void AddFeelings(this Dictionary <string, List <string> > dictionary, PartyGoer partyGoer, string trackUri)
 {
     if (dictionary.ContainsKey(partyGoer.GetId()))
     {
         dictionary[partyGoer.GetId()].TryAdd(trackUri);
     }
     else
     {
         dictionary.Add(partyGoer.GetId(), new List <string> {
             trackUri
         });
     }
 }