コード例 #1
0
        public async Task<IActionResult> Update([FromRoute] int id, [FromQuery] int broadcasterId, [FromBody] Reminders reminder)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != reminder.Id && broadcasterId != reminder.Broadcaster)
            {
                return BadRequest();
            }

            _context.Entry(reminder).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!RemindersExists(id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return NoContent();
        }
コード例 #2
0
        public async Task <IActionResult> UpdateExp([FromRoute] int broadcasterId, [FromQuery] string username, [FromQuery] int exp)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            RankFollowers follower = _context.RankFollowers.FirstOrDefault(t => t.Broadcaster == broadcasterId && t.Username == username);

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

            follower.Exp = exp;
            _context.RankFollowers.Update(follower);

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!RankFollowersExists(broadcasterId, username))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
コード例 #3
0
        public async Task <IActionResult> Update([FromRoute] int broadcasterId, [FromBody] BankHeistSettings bankHeistSettings)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (broadcasterId != bankHeistSettings.Broadcaster)
            {
                return(BadRequest());
            }

            _context.Entry(bankHeistSettings).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!BankHeistSettingsExists(broadcasterId))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
コード例 #4
0
        public async Task <IActionResult> Update([FromRoute] int broadcasterId, [FromQuery] int id, [FromBody] SongRequestBlacklist songRequestBlacklist)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != songRequestBlacklist.Id && broadcasterId != songRequestBlacklist.Broadcaster)
            {
                return(BadRequest());
            }

            _context.Entry(songRequestBlacklist).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SongRequestBlacklistExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Ok(songRequestBlacklist));
        }
コード例 #5
0
        public async Task <IActionResult> Update([FromRoute] int settingsId, [FromQuery] int id, [FromBody] BossFightClassStats bossFightClassStats)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != bossFightClassStats.Id || settingsId != bossFightClassStats.SettingsId)
            {
                return(BadRequest());
            }

            _context.Entry(bossFightClassStats).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!BossFightClassStatsExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
コード例 #6
0
        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));
        }
コード例 #7
0
        public async Task <IActionResult> Create([FromBody] PartyUpRequests partyUpRequest)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (PartyUpRequestExists(partyUpRequest.Username, partyUpRequest.Broadcaster))
            {
                return(BadRequest());
            }

            _context.PartyUpRequests.Add(partyUpRequest);
            await _context.SaveChangesAsync();

            return(NoContent());
        }
コード例 #8
0
        public async Task <IActionResult> Create([FromBody] Moderators moderator)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (ModeratorExists(moderator.Username, moderator.Broadcaster))
            {
                return(BadRequest());
            }

            _context.Moderators.Add(moderator);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("Get", new { broadcasterId = moderator.Broadcaster }, moderator));
        }
コード例 #9
0
        public async Task <IActionResult> Create([FromBody] ErrorLog errorLog)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.ErrorLog.Add(errorLog);
            await _context.SaveChangesAsync();

            return(NoContent());
        }
コード例 #10
0
ファイル: BanksController.cs プロジェクト: Faded/TwitchBot
        public async Task <IActionResult> UpdateAccount([FromRoute] int broadcasterId, [FromQuery] int updatedWallet, [FromQuery] string username)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            Bank bankAccount = _context.Bank.FirstOrDefault(t => t.Broadcaster == broadcasterId && t.Username == username);

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

            bankAccount.Wallet = updatedWallet;

            _context.Bank.Update(bankAccount);
            await _context.SaveChangesAsync();

            return(NoContent());
        }
コード例 #11
0
        public async Task <IActionResult> Update([FromRoute] int twitchId, [FromBody] Broadcasters broadcaster)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (twitchId != broadcaster.TwitchId)
            {
                return(BadRequest());
            }

            Broadcasters updatedbroadcaster = await _context.Broadcasters.FirstOrDefaultAsync(m => m.TwitchId == twitchId);

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

            updatedbroadcaster.Username = broadcaster.Username;
            _context.Broadcasters.Update(updatedbroadcaster);

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!BroadcasterExists(twitchId))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
コード例 #12
0
ファイル: QuotesController.cs プロジェクト: Faded/TwitchBot
        public async Task <IActionResult> Patch([FromRoute] int id, [FromQuery] int broadcasterId, [FromBody] JsonPatchDocument <Quote> quotePatch)
        {
            Quote quote = _context.Quote.SingleOrDefault(m => m.Id == id && m.Broadcaster == broadcasterId);

            if (quote == null)
            {
                return(BadRequest());
            }

            quotePatch.ApplyTo(quote, ModelState);

            if (!ModelState.IsValid)
            {
                return(new BadRequestObjectResult(ModelState));
            }

            _context.Quote.Update(quote);

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!QuoteExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
コード例 #13
0
        public async Task <IActionResult> Patch([FromRoute] int broadcasterId, [FromQuery] string username, [FromBody] JsonPatchDocument <UserBotTimeout> botTimeoutPatch)
        {
            UserBotTimeout userBotTimeout = _context.UserBotTimeout.SingleOrDefault(m => m.Username == username && m.Broadcaster == broadcasterId);

            if (userBotTimeout == null)
            {
                return(BadRequest());
            }

            botTimeoutPatch.ApplyTo(userBotTimeout, ModelState);

            if (!ModelState.IsValid)
            {
                return(new BadRequestObjectResult(ModelState));
            }

            _context.UserBotTimeout.Update(userBotTimeout);

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UserBotTimeoutExists(broadcasterId, username))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Ok(userBotTimeout));
        }