public void ArchiveCurrentRequest(int songId = 0)
        {
            var currentRequest = songId == 0 ? _currentRequest :
                                 songId == _currentRequest.songRequestId ? _currentRequest : null;

            if (currentRequest == null)
            {
                return;
            }

            _archiveRequestCommand.ArchiveRequest(currentRequest.songRequestId, false);

            UpdateFullPlaylist(true);
            // TODO SignalR Update
        }
        public async Task <bool> ArchiveAndRefundVips(string username, SongRequestType songRequestType, int currentSongRequestId)
        {
            var usersRequests = _getUsersRequestsRepository.GetUsersRequests(username);

            int songRequestId = 0;

            switch (songRequestType)
            {
            case SongRequestType.Regular:
                songRequestId = usersRequests.SingleOrDefault(r => !r.IsVip)?.SongRequestId ?? 0;
                break;

            case SongRequestType.Vip:
                songRequestId = usersRequests.SingleOrDefault(r => r.IsVip && !r.IsSuperVip)?.SongRequestId ?? 0;
                break;

            case SongRequestType.SuperVip:
                songRequestId = usersRequests.SingleOrDefault(r => r.IsSuperVip)?.SongRequestId ?? 0;
                break;

            default:
                return(false);
            }

            if (songRequestId == 0 || songRequestId == currentSongRequestId)
            {
                return(false);
            }

            await _archiveRequestCommand.ArchiveRequest(songRequestId, true).ConfigureAwait(false);

            return(true);
        }
Exemplo n.º 3
0
        public async Task <bool> Remove(string username, int playlistPosition)
        {
            var usersRequests = _getUsersRequestsRepository.GetUsersRequests(username);

            if (usersRequests == null || !usersRequests.Any())
            {
                return(false);
            }

            var request = usersRequests.SingleOrDefault(r => r.PlaylistPosition == playlistPosition);

            if (request == null)
            {
                return(false);
            }

            await _archiveRequestCommand.ArchiveRequest(request.SongRequestId, true);

            return(true);
        }