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);
        }
        public List <string> GetUsersFormattedRequests(string username)
        {
            var usersRequests = _getUsersRequestsRepository.GetUsersRequests(username);

            var formattedUserRequests = usersRequests.Select(sr =>
                                                             sr.IsVip ? $"{sr.PlaylistPosition} - {sr.SongRequestsText}" : sr.SongRequestsText).ToList();

            return(formattedUserRequests);
        }
Beispiel #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);
        }