public async Task <IActionResult> DeleteQuote([FromBody] QuoteActionModel quoteActionModel)
        {
            var success = false;

            try
            {
                if (ModelState.IsValid && HttpContext.User.Identity.IsAuthenticated)
                {
                    success = await _quoteApiClient.RemoveQuote(new RemoveQuoteRequest
                    {
                        QuoteId  = quoteActionModel.QuoteId,
                        Username = HttpContext.User.Identity.Name,
                        IsMod    = _modService.IsUserModerator(HttpContext.User.Identity.Name)
                    });
                }
            }
            catch (Exception)
            {
                success = false;
            }

            if (!success)
            {
                return(BadRequest());
            }

            return(Ok());
        }
Exemplo n.º 2
0
        public async void Process(TwitchClient client, string username, string commandText, bool isMod, JoinedChannel joinedChannel)
        {
            var commandTerms = commandText.SplitCommandText();

            if (!int.TryParse(commandTerms[0], out var quoteId))
            {
                client.SendMessage(joinedChannel, $"Hey @{username}, looks like you didn't provide a Quote number for me to remove!");
                return;
            }

            var response = await _quoteApiClient.RemoveQuote(new RemoveQuoteRequest
            {
                QuoteId  = quoteId,
                Username = username,
                IsMod    = isMod
            });

            client.SendMessage(joinedChannel,
                               response
                    ? $"Hey @{username}, I have removed that quote for you!"
                    : $"Hey @{username}, I'm sorry I couldn't remove that quote. Is that one you created?");
        }