Пример #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 });
            }
        }
Пример #2
0
        public async Task <bool> AddNewSongToQueue(AddSongToQueueRequest request)
        {
            try
            {
                Party party = await _partyRepository.GetPartyWithCode(request.PartyCode);

                await party.ModifyPlaylistAsync(request);

                return(true);
            }
            catch (Exception ex)
            {
                await _logService.LogExceptionAsync(ex, "Error occured in AddNewSongToQueue");

                return(false);
            }
        }