예제 #1
0
        public async Task UserAddedSong(AddSongToQueueRequest request)
        {
            PartyGoer partier = new PartyGoer(Context.UserIdentifier);

            request.AddedBy = partier.Id;
            bool successfullyAddedSongToQueue = await _partyService.AddNewSongToQueue(request);

            if (successfullyAddedSongToQueue)
            {
                Party party = await _partyService.GetPartyWithAttendeeAsync(partier);

                // Update the view of the partier to the current playlist
                await Clients.Group(party.PartyCode).SendAsync("UpdatePartyView",
                                                               new
                {
                    Song     = party.Playlist.CurrentSong,
                    Position = party.Playlist.CurrentPositionInSong()
                },
                                                               party.Playlist.History,
                                                               party.Playlist.Queue
                                                               );
            }
            else
            {
                await Clients.Client(Context.ConnectionId).SendAsync("UserModifiedPlaylist", new { error = true });
            }
        }