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 edit!"); return; } var newText = string.Join(" ", commandTerms.Skip(1)); var response = await _quoteApiClient.EditQuote(new EditQuoteRequest { QuoteId = quoteId, QuoteText = newText, Username = username, IsMod = isMod }); client.SendMessage(joinedChannel, response ? $"Hey @{username}, I have updated that quote for you!" : $"Hey @{username}, I'm sorry I couldn't update that quote. Is that one you created?"); }
public async Task <IActionResult> EditQuote([FromBody] QuoteActionModel quoteActionModel) { var success = false; try { if (ModelState.IsValid && HttpContext.User.Identity.IsAuthenticated && !string.IsNullOrWhiteSpace(quoteActionModel.Text)) { success = await _quoteApiClient.EditQuote(new EditQuoteRequest { QuoteId = quoteActionModel.QuoteId, QuoteText = quoteActionModel.Text, Username = HttpContext.User.Identity.Name, IsMod = _modService.IsUserModerator(HttpContext.User.Identity.Name) }); } } catch (Exception) { success = false; } if (!success) { return(BadRequest()); } return(Ok()); }