public async Task <SongRequests> AddSongRequest(string songRequestName, string username, int broadcasterId)
        {
            SongRequests songRequest = new SongRequests
            {
                Requests    = songRequestName,
                Chatter     = username,
                Broadcaster = broadcasterId
            };

            return(await ApiBotRequest.PostExecuteTaskAsync(_twitchBotApiLink + $"songrequests/create", songRequest));
        }
        public async Task <IActionResult> Create([FromBody] SongRequests songRequests)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.SongRequests.Add(songRequests);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("Get", new { broadcasterId = songRequests.Broadcaster }, songRequests));
        }
        public async Task <IActionResult> Delete([FromRoute] int broadcasterId, [FromQuery] bool popOne = false)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var songRequests = new object();

            if (popOne)
            {
                SongRequests songRequest = await _context.SongRequests
                                           .Where(m => m.Broadcaster == broadcasterId)
                                           .OrderBy(m => m.Id)
                                           .Take(1)
                                           .SingleOrDefaultAsync();

                if (songRequest == null)
                {
                    return(NotFound());
                }

                _context.SongRequests.Remove(songRequest);

                songRequests = songRequest;
            }
            else
            {
                List <SongRequests> removedSong = await _context.SongRequests.Where(m => m.Broadcaster == broadcasterId).ToListAsync();

                if (removedSong == null || removedSong.Count == 0)
                {
                    return(NotFound());
                }

                _context.SongRequests.RemoveRange(removedSong);

                songRequests = removedSong;
            }

            await _context.SaveChangesAsync();

            return(Ok(songRequests));
        }
Beispiel #4
0
        /// <summary>
        /// Removes the first song in the queue of song requests
        /// </summary>
        public async Task CmdPopManualSr()
        {
            try
            {
                SongRequests removedSong = await _manualSongRequest.PopSongRequest(_broadcasterId);

                if (removedSong != null)
                {
                    _irc.SendPublicChatMessage($"The first song in the queue, \"{removedSong.Requests}\" ({removedSong.Chatter}), has been removed");
                }
                else
                {
                    _irc.SendPublicChatMessage("There are no songs that can be removed from the song request list");
                }
            }
            catch (Exception ex)
            {
                await _errHndlrInstance.LogError(ex, "CmdMod", "CmdPopManualSr()", false, "!poprbsr");
            }
        }