Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 4
0
 public void DeleteWord(int wordID)
 {
     WordsRepository.DeleteWord(wordID);
 }
Exemplo n.º 5
0
 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"));
        }