Exemplo n.º 1
0
        public async Task UserAddedSong(AddSongToQueueCommand request)
        {
            PartyGoer partier = await _partyGoerService.GetCurrentPartyGoerAsync();

            request.AddedBy = partier.GetUsername();
            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.GetPartyCode()).SendAsync("UpdatePartyView",
                                                                    new
                {
                    Song     = party.GetCurrentSong(),
                    Position = party.GetCurrentPositionInSong()
                },
                                                                    party.GetHistory(),
                                                                    party.GetQueue()
                                                                    );
            }
            else
            {
                await Clients.Client(Context.ConnectionId).SendAsync("UserModifiedPlaylist", new { error = true });
            }
        }