private WordDTO parseSynonymSection(string html) { WordDTO results = new WordDTO(); string temp = html; int locationA = 0; int locationB = 0; locationA = temp.IndexOf("<em class"); locationA = temp.IndexOf(">", locationA); locationB = temp.IndexOf("<", locationA); string pos = temp.Substring(locationA + 1, locationB - locationA - 1); if (pos == "adj") { pos = "Adjective"; } if (pos == "conj") { pos = "Conjunction"; } // results.partOfSpeech = pos; results.synonyms = getSynonyms(temp); results.antonyms = getListOfAntonyms(temp); return(results); }
private List <WordDTO> ParseThesaurusPage(string sLine) { List <WordDTO> results = new List <WordDTO>(); int i = 0; List <string> synonymGroups = new List <string>(); int thisOne = 0; while (sLine.IndexOf("<div id=\"synonyms-" + i.ToString()) > 0) { thisOne = sLine.IndexOf("<div id=\"synonyms-" + i.ToString()); int next = sLine.IndexOf("</section>", thisOne); string temp = sLine.Substring(thisOne, "</section>".Length + next - thisOne); synonymGroups.Add(temp); i++; } foreach (var syng in synonymGroups) { WordDTO tmp = parseSynonymSection(syng); tmp.word = Word; results.Add(tmp); } return(results); }
public IActionResult Update(int id, [FromBody] Word Words) { var obj = _repository.GetOne(id); if (obj == null) { return(StatusCode(404)); } if (Words == null) { return(StatusCode(400)); } if (!ModelState.IsValid) { return(UnprocessableEntity(ModelState)); } Words.Id = id; Words.Status = obj.Status; Words.Creation = obj.Creation; Words.Update = DateTime.Now; _repository.Update(Words); WordDTO wordDTO = _mapper.Map <Word, WordDTO>(Words); wordDTO.Links.Add(new LinkDTO("self", Url.Link("GetWord", new { id = wordDTO.Id }), "GET")); return(Ok(wordDTO)); }
public List <WordDTO> SearchWords(string directoryPath, string id, string query) { var fileName = directoryPath + id; var wordsDTO = new List <WordDTO>(); var fileContent = File.ReadAllText(fileName); var words = fileContent .Split(' ') .Where(x => x.Length >= 5 && x.Contains(query)) .GroupBy(x => x) .Select(x => new { KeyField = x.Key, Count = x.Count() }) .OrderByDescending(x => x.Count); foreach (var word in words) { var wordDTO = new WordDTO(); wordDTO.Word = word.KeyField[0].ToString().ToUpper() + word.KeyField.Substring(1); wordDTO.Count = word.Count; wordsDTO.Add(wordDTO); } return(wordsDTO); }
public void CreateWord(WordDTO wordDTO) { Word word = null; try { word = db.Words.Find(p => p.Name == wordDTO.Name).FirstOrDefault(); } catch { } User user = db.Users.Find(p => p.ChatId == wordDTO.UserChatId).FirstOrDefault(); if (word == null) { word = new Word(); word.Name = wordDTO.Name; db.Words.Create(word); } word.UserWords.Add(new UsersWords { User = user, Word = word }); db.Save(); }
public static WordDTO MapWordDTO(Word word) { WordDTO newWord = new WordDTO(word.EnglshTranslation, word.UkrainianTranslation, word.Id, word.Topic.Id); newWord.Topic = MapTopicDTO(word.Topic); return(newWord); }
public ActionResult PostWord([FromBody] WordDTO wordDTO) { wordsService.CreateWord(wordDTO); int wordId = 0; return(Created($"{Request.Path}/{wordId}", wordDTO)); }
public Card5(WordDTO wordToLearn) { try { InitializeComponent(); border.Background = new SolidColorBrush(Color.FromArgb(177, 204, 229, 255)); this.wordToLearn = wordToLearn; translation.Text = wordToLearn.Translation; StringBuilder starsString = new StringBuilder(); for (int i = 0; i < wordToLearn.WordEng.Count(); i++) { starsString.Append('*'); } stars.Text = starsString.ToString(); Dispatcher.BeginInvoke(DispatcherPriority.Input, new Action(delegate() { enteredWord.Focus(); Keyboard.Focus(enteredWord); })); parentWindow.nextCardButton.IsEnabled = false; } catch (Exception ex) { Helper.log.Error(ex.ToString()); MaterialMessageBox.ShowError(ex.ToString()); } }
public bool AddWord(WordDTO wordDTO, int dictionaryId) { var word = MappingWord.MappingDTOtoDM(wordDTO); word.Dictionary = _dal.GetDictionary(dictionaryId); return(_dal.AddWord(word)); }
public Card1(WordDTO word) { InitializeComponent(); wordEng.Text = word.WordEng; transcription.Text = word.Transcription; translation.Text = word.Translation; DataContext = Helper.LoadImage(word.Image); }
public static WordDTO MapWordDTO(WordViewModel word) { WordDTO newWord = new WordDTO(word.Englsh, word.Ukrainian, word.Id); // WordDTO newWord = new WordDTO(word.Englsh, word.Ukrainian, word.Id, word.Topic.Id); //newWord.Topic = MapTopicDTO(word.Topic); return(newWord); }
public async Task <IActionResult> Add(WordDTO word) { var entity = Mapper.Map(word); await _quizRepository.AddWordAsync(word.ParentId, entity); await _unitOfWork.CompleteAsync(); return(Accepted()); }
public ActionResult GetWord(int id) { WordDTO wordDTO = wordsService.GetWord(id); if (wordDTO == null) { return(NotFound()); } return(Ok(wordDTO)); }
public WordDTO GetWordDTO(h_word templateSource) { WordDTO word = new WordDTO(); word.name = templateSource.Name; word.sysid = templateSource.Sysid; word.vecotr = templateSource.Vector; word.isfirst = templateSource.IsFirst; return(word); }
public static WordDC MappingDTOtoDC(WordDTO wordDTO) { MapperConfiguration configDTOtoDC = new MapperConfiguration(cfg => { cfg.CreateMap <WordDTO, WordDC>(); }); IMapper iMapper = configDTOtoDC.CreateMapper(); return(iMapper.Map <WordDTO, WordDC>(wordDTO)); }
public static Word MapWord(WordDTO word) { return(new Word() { Id = word.Id, TopicId = word.TopicId, EnglshTranslation = word.Englsh, UkrainianTranslation = word.Ukrainian, // Topic = MapTopic(word.Topic) }); }
public static WordViewModel MapWord(WordDTO word) { return(new WordViewModel(word.Englsh, word.Ukrainian, word.Id, word.TopicId) { // Id = word.Id, // TopicId = word.TopicId, // Englsh = word.Englsh, // Ukrainian = word.Ukrainian, // Topic = MapTopic(word.Topic) }); }
public ActionResult PutWord(int id, [FromBody] WordDTO wordDTO) { int rowAffected = wordsService.EditWord(wordDTO).Result; if (rowAffected == -1) { return(NotFound()); } return(Ok()); }
public bool Add(WordDTO data) { try { return(dal.Add(data)); } catch (NullReferenceException e) { throw e; } }
public async override Task Execute(Message message, TelegramBotClient telegramBotClient) { ChatId chatId = message.Chat.Id; string wordName = message.Text.Substring(message.Text.IndexOf(" ") + 1); WordDTO wordDTO = new WordDTO(); wordDTO.Name = wordName; wordDTO.UserChatId = message.Chat.Id; wordsService.CreateWord(wordDTO); await telegramBotClient.SendTextMessageAsync(chatId, "word created"); }
private void FormationCard5() { try { WordDTO wordToLearn = RandWord(4); contentControl.Content = new Card5(wordToLearn); } catch (Exception ex) { Helper.log.Error(ex.ToString()); MaterialMessageBox.ShowError(ex.ToString()); } }
public static WordDC MappingDTOtoDC(WordDTO wordDTO) { MapperConfiguration configDTOtoDC = new MapperConfiguration(cfg => { cfg.CreateMap <WordDTO, WordDC>().MaxDepth(2); cfg.CreateMap <DictionaryExtnDTO, DictionaryExtnDC>().MaxDepth(2); }); configDTOtoDC.AssertConfigurationIsValid(); IMapper iMapper = configDTOtoDC.CreateMapper(); return(iMapper.Map <WordDTO, WordDC>(wordDTO)); }
public static Word MappingDTOtoDM(WordDTO wordDTO) { var config = new MapperConfiguration(cfg => { cfg.CreateMap <WordDTO, Word>().MaxDepth(2); cfg.CreateMap <DictionaryExtnDTO, DictionaryExtn>().MaxDepth(2); }); config.AssertConfigurationIsValid(); var mapper = config.CreateMapper(); return(mapper.Map <WordDTO, Word>(wordDTO)); }
private void FormationCard4() { try { WordDTO wordToLearn = RandWord(3); Helper.PlaySoundFromBytes(wordToLearn.Sound); contentControl.Content = new Card4(wordToLearn); } catch (Exception ex) { Helper.log.Error(ex.ToString()); MaterialMessageBox.ShowError(ex.ToString()); } }
public Task <int> EditWord(WordDTO wordDTO) { //Think about automapper Word word = db.Words.Find(w => w.Id == wordDTO.Id).SingleOrDefault(); if (word == null) { return(Task.FromResult(-1)); } word.Name = wordDTO.Name; db.Words.Update(word); db.Save(); return(Task.FromResult(1)); }
public WordDTO GetWord(int id) { WordDTO wordDTO = new WordDTO(); try { Word word = db.Words.Find(w => w.Id == id).SingleOrDefault(); wordDTO.Id = word.Id; wordDTO.Name = word.Name; } catch { return(null); } return(wordDTO); }
private void Translation_Click(object sender, RoutedEventArgs e) { try { if (wordEng != null) { translation = (((((sender as Button).Content) as Viewbox).Child) as TextBlock).Text; WordDTO word = wordsToLearn.Where(item => item.WordEng == wordEng).Single(); if (word.Translation == translation) { (sender as Button).Background = Brushes.LightGreen; (sender as Button).IsHitTestVisible = false; wordEngButtom.Background = Brushes.LightGreen; wordEngButtom.IsHitTestVisible = false; CountCorrectlySelectedWords++; parentWindow.WordsToLearn.Where(x => x.Id == word.Id).SingleOrDefault().IsCardPassed[1] = true; } else { Storyboard sb = FindResource("mistakeAnimation") as Storyboard; Storyboard.SetTarget(sb, (sender as Button)); sb.Begin(); (sender as Button).Focusable = false; foreach (var item in card2Grid.Children) { if (item is Button && (item as Button).Content != null && (item as Button).Content.Equals(wordEng)) { (item as Button).Background = Brushes.Transparent; } } } if (CountCorrectlySelectedWords.Equals(wordsToLearn.Count)) { parentWindow.nextCardButton.IsEnabled = true; } wordEng = null; } } catch (Exception ex) { Helper.log.Error(ex.ToString()); MaterialMessageBox.ShowError(ex.ToString()); } }
public int InsertWord(WordDTO wd) { int wordId = 0; try { using (SqlCommand cmd = new SqlCommand("sp_insert_word", con)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@word", SqlDbType.VarChar).Value = wd.word; // cmd.Parameters.Add("@PartOfSpeech", SqlDbType.VarChar).Value = wd.partOfSpeech; if (con.State == ConnectionState.Closed) { con.Open(); } SqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { wordId = (int)rdr[0]; } rdr.Close(); } foreach (var syn in wd.synonyms) { insertSynonyms(wordId, syn); } foreach (var ant in wd.antonyms) { insertAntonyms(wordId, ant); } } catch (Exception ex) { string message = ex.Message; throw; } finally { con.Close(); } return(wordId); }
public ResponseDTO <WordDTO> Update([FromBody] WordDTO dto) { ResponseDTO <WordDTO> result = new Base.ResponseDTO <WordDTO>(); try { _WordService.Update(dto.Id, dto); result.StatusCode = 200; //OK result.Data = dto; } catch (Exception e) { result.StatusCode = 500; //Error result.Message = e.Message; } return(result); }
public IActionResult GetOne(int id) { var obj = _repository.GetOne(id); if (obj == null) { return(StatusCode(404)); } WordDTO wordDTO = _mapper.Map <Word, WordDTO>(obj); wordDTO.Links.Add(new LinkDTO("self", Url.Link("GetWord", new { id = wordDTO.Id }), "GET")); wordDTO.Links.Add(new LinkDTO("update", Url.Link("UpdateWord", new { id = wordDTO.Id }), "PUT")); wordDTO.Links.Add(new LinkDTO("delete", Url.Link("DeleteWord", new { id = wordDTO.Id }), "DELETE")); return(Ok(wordDTO)); }