public ObservableCollection<Item> GetRndWords(int cnt,SpeechParts speechpart_ = null)
        {

            ObservableCollection<Item> coll = new ObservableCollection<Item>();
            Random rnd = new Random();
            for (int i = 0; i < cnt; i++)
            {
                int rndindex = rnd.Next(1, Count);
                coll.Add(EFDbContext.DataBase.FrequencyDictionaryItems.FirstOrDefault(x=>x.FrequencyDictionary_id == id && x.number == rndindex));
            }
            
            /*
            RangeOfSpeechParts range = ViewModelLocator.Instance.DataBase.Set<RangeOfSpeechParts>().Where(x => x.speechpart.id == speechpart_.id).FirstOrDefault();
            if(range != null)
            {
                Random rnd = new Random();
                for (int i = 0; i < Count; i++)
                {

                    int minelm = range.StartId;
                    int maxelm = range.StartId + range.Count -1;

                    coll.Add(ViewModelLocator.Instance.DataBase.Set<Item>().Find(rnd.Next(minelm,maxelm)));
                }
            }*/
            return coll;    
        }
Exemplo n.º 2
0
 public void AddTranslationWithExternalId(int external_id_,string str_translation,SpeechParts part)
 {
     
     TranslationOfWord translation = translations.Where(x => x.external_id == external_id_).FirstOrDefault();
     if (translation == null)
     {
         translation = new TranslationOfWord();
         translations.Add(translation);
         
     }
     translation.external_id = external_id_;
     translation.translation = str_translation;
     translation.speechpart = part;
     RaisePropertyChanged(()=>translation_as_string);
 }