public JsonResult Index() { var messageText = "Le petit @sobaque kek_kek pek PEK !!!"; var words = Word.GetWordsFromText(messageText); var chat = new Chat { TelegramID = 666, Name = "Some funny chat" }; _wordsRepo.Create(words); _wordsRepo.GetContext().SaveChanges(); _chatsRepo.Create(chat); _chatsRepo.GetContext().SaveChanges(); _usagesRepo.IncrementLinks(words, chat); _usagesRepo.GetContext().SaveChanges(); return(Json(_usagesRepo.GetBy(usage => usage.ChatID == chat.ID).ToList())); }
private IWcbTelegramBotAction handleGenericMessage(Update update) { var chat = new MyChat { Name = update.Message.Chat.Title, TelegramID = update.Message.Chat.Id }; var text = Word.EscapeString(update.Message.Text); var words = Word.GetWordsFromText(text).Where(word => !word.TooShort).ToList(); if (words.Count == 0) { return(null); } _chatsRepo.Create(chat); _chatsRepo.GetContext().SaveChanges(); _wordsRepo.Create(words); _wordsRepo.GetContext().SaveChanges(); _usagesRepo.IncrementLinks(words, chat); return(null); }