예제 #1
0
        public void FillSpeak(long languageId)
        {
            ISpeaker speaker = _speakerFactory.Create(languageId);

            Adapter.ActionByContext(c => {
                IQueryable <Sentence> sentencesQuery = (from s in c.Sentence
                                                        where s.LanguageId == languageId && s.Pronunciation == null
                                                        select s);
                List <Sentence> sentences = sentencesQuery.ToList();
                foreach (Sentence sentence in sentences)
                {
                    sentence.Pronunciation = speaker.ConvertTextToAudio(sentence.Text);
                    c.SaveChanges();
                }
            });
        }
예제 #2
0
        public void FillSpeak(long languageId)
        {
            ISpeaker speaker = _speakerFactory.Create(languageId);

            Adapter.ActionByContext(c => {
                IQueryable <Word> wordsQuery = (from w in c.Word
                                                where w.LanguageId == languageId && w.Pronunciation == null
                                                select w);
                List <Word> words = wordsQuery.ToList();
                foreach (Word word in words)
                {
                    word.Pronunciation = speaker.ConvertTextToAudio(word.Text);
                    c.SaveChanges();
                }
            });
        }
예제 #3
0
        private Word AddWord(StudyLanguageContext c,
                             long languageId,
                             string text,
                             WordType wordType)
        {
            ISpeaker speaker        = _speakerFactory.Create(languageId);
            string   normalizedText = NormalizeTextWord(text);

            var result = new Word {
                LanguageId    = languageId,
                Text          = normalizedText,
                Type          = (int)wordType,
                Pronunciation = speaker.ConvertTextToAudio(normalizedText)
            };

            c.Word.Add(result);
            return(result);
        }
예제 #4
0
        private Sentence GetOrAddSentenceToContext(long languageId, string text, StudyLanguageContext context)
        {
            string trimmedText = text.Trim();
            IQueryable <Sentence> sentenceQuery = from s in context.Sentence
                                                  where s.LanguageId == languageId && s.Text == trimmedText
                                                  select s;
            Sentence result = sentenceQuery.FirstOrDefault();

            if (result == null)
            {
                ISpeaker speaker = _speakerFactory.Create(languageId);
                result = new Sentence
                {
                    LanguageId = languageId, Text = trimmedText, Pronunciation = speaker.ConvertTextToAudio(trimmedText)
                };
                context.Sentence.Add(result);
            }
            return(result);
        }