public override AnswerItem Reply(MessageItem mItem) { IReplyMarkup markup = null; string message; if (string.IsNullOrEmpty(mItem.TextOnly)) { message = "Type a chinese word to remove it from the dictionary. All word's score information will be removed too!"; } else if (NoAnswer == mItem.TextOnly.ToLowerInvariant()) { message = "Delete has been cancelled"; } else if (mItem.TextOnly.ToLowerInvariant().StartsWith(YesAnswer)) { try { var wordText = mItem.TextOnly.Replace(YesAnswer, string.Empty); var word = _repository.GetWord(wordText, mItem.ChatId); if (word == null) { message = $"Word {wordText} is not found"; } else { _repository.DeleteWord(word.Id); message = $"Word {word.OriginalWord} has been removed"; } } catch (Exception e) { message = e.Message; } } else { message = $"Do you really want to remove '{mItem.TextOnly}'?"; markup = new InlineKeyboardMarkup(new[] { new InlineKeyboardButton { Text = "✅Yes", CallbackData = $"yes{mItem.TextOnly}" }, new InlineKeyboardButton { Text = "❌No", CallbackData = "no" } }); } var answer = new AnswerItem { Message = message, Markup = markup }; return(answer); }
public ActionResult DeleteWord(int id) { var word = _wordRepository.GetWord(id); if (word == null) { return(NotFound()); } _wordRepository.DeleteWord(id); return(NoContent()); }
public WordEditInfoModel DeleteWord(WordEditInfoModel wordEditInfoModel, string userIp) { bool hasCreditsToDelete = _userManagingService.CheckIfValidToSearch(userIp); if (!hasCreditsToDelete) { wordEditInfoModel.EditStatus = WordEditStatus.DeleteDenied; return(wordEditInfoModel); } _wordRepository.DeleteWord(wordEditInfoModel.OriginalWord); wordEditInfoModel.EditStatus = WordEditStatus.DeleteSuccesful; return(wordEditInfoModel); }
public void DeleteWord(int wordID) { WordsRepository.DeleteWord(wordID); }
public IActionResult Delete(WordModel model) { repo.DeleteWord(model.WordId); return(RedirectToAction("Index")); }
public ActionResult DeleteWord(Word word) { repository.DeleteWord(word.WordID); return(RedirectToAction("Index", "Home")); }