EFDbConnect CreateDemoBase(string db_name)
        {
            string path = PathToDb(db_name);
            if (File.Exists(path))
            {
                File.Delete(path);
            }

            ILogger ILoggerMock = Mock.Of<ILogger>();
            ISQLitePlatform platf = new SQLitePlatformWin32();
            EFDbConnect EFDbConnect = new EFDbConnect(platf, path);

            EFDbContext ctx = new EFDbContext(EFDbConnect);

            LearningItem li1 = new LearningItem();
            li1.Name = "First";
            ctx.AddNewItemToDBContext(li1);
            LearningItem li2 = new LearningItem();
            li2.Name = "Second";
            ctx.AddNewItemToDBContext(li2);


            // Audio tracks
            AudioTrack at1 = new AudioTrack();
            li1.AudioTracks.Add(at1);

            AudioTrack at2 = new AudioTrack();
            li1.AudioTracks.Add(at2);

            AudioTrack at3 = new AudioTrack();
            li2.AudioTracks.Add(at3);

            // Frequency dictionary
            FrequencyDictionary fd1 = new FrequencyDictionary();
            FrequencyDictionary fd2 = new FrequencyDictionary();

            FrequencyDictionary.Item fdi1 = new FrequencyDictionary.Item();
            fd1.Items.Add(fdi1);
            FrequencyDictionary.Item fdi2 = new FrequencyDictionary.Item();
            fd1.Items.Add(fdi2);

            FrequencyDictionary.Item fdi3 = new FrequencyDictionary.Item();
            fd2.Items.Add(fdi3);
            FrequencyDictionary.Item fdi4 = new FrequencyDictionary.Item();
            fd2.Items.Add(fdi4);

            // Languages
            Language lang1 = new Language();
            lang1.FrequencyDictionary = fd1;

            Language lang2 = new Language();
            lang2.FrequencyDictionary = fd2;

            Subtitles sub1 = new Subtitles();
            li1.SubtitleCollection.Add(sub1);
            sub1.SecondaryLanguage = lang1;

            Subtitles sub2 = new Subtitles();
            li1.SubtitleCollection.Add(sub2);


            SubtitleItem si1 = new SubtitleItem();
            sub1.Items.Add(si1);
            SubtitleItem si2 = new SubtitleItem();
            sub1.Items.Add(si2);

            SubtitleItem si3 = new SubtitleItem();
            sub2.Items.Add(si3);
            SubtitleItem si4 = new SubtitleItem();
            sub2.Items.Add(si4);

            Subtitles sub3 = new Subtitles();
            li2.SubtitleCollection.Add(sub3);
            sub3.SecondaryLanguage = lang2;

            SubtitleItem si5 = new SubtitleItem();
            sub3.Items.Add(si5);


            WordOfSubtitleItem sw1 = new WordOfSubtitleItem();
            si1.WordsCollection.Add(sw1); 

            WordOfSubtitleItem sw2 = new WordOfSubtitleItem();
            si1.WordsCollection.Add(sw2); 

            WordOfSubtitleItem sw3 = new WordOfSubtitleItem();
            si5.WordsCollection.Add(sw3);



            // Dictionary
            Dictionary dic1 = new Dictionary();
            ctx.AddNewItemToDBContext(dic1);

            WordOfDictionary wd1 = new WordOfDictionary();
            dic1.Words.Add(wd1);

            TranslationOfWord tw1 = new TranslationOfWord();
            wd1.translations.Add(tw1);
            
            TranslationOfWord tw2 = new TranslationOfWord();
            wd1.translations.Add(tw2);

            WordOfDictionary wd2 = new WordOfDictionary();
            dic1.Words.Add(wd2);
            sw1.word_of_dictionary = wd1;
            sw2.word_of_dictionary = wd2;

            Dictionary dic2 = new Dictionary();
            ctx.AddNewItemToDBContext(dic2);
            WordOfDictionary wd3 = new WordOfDictionary();
            dic1.Words.Add(wd3);
            WordOfDictionary wd4 = new WordOfDictionary();
            dic1.Words.Add(wd4);
            sw3.word_of_dictionary = wd3;

            
            
            
            ctx.SaveChanges();

            return EFDbConnect;
        }
        private void InitializeFrequencyDictionary()
        {

            return;

            string url = "http://dict.ruslang.ru/";
            FrequencyDictionary fd =  DataBase.Table<FrequencyDictionary>().Where(x=>x.Url == url).FirstOrDefault();
            if(fd == null)
            {

                List<FrequencyDictionary.Item> items = new List<FrequencyDictionary.Item>();

                using (TextReader reader = File.OpenText("Resources/russian_freq_dict.txt"))
                {
                    // header
                    string line = reader.ReadLine();

                    Dictionary<string, SpeechParts> dict = new Dictionary<string, SpeechParts>();
                    dict.Add("s",SpeechParts.Noun);
                    dict.Add("spro",SpeechParts.Pronoun);
                    dict.Add("v",SpeechParts.Verb);
                    dict.Add("a",SpeechParts.Adjective);

                    dict.Add("pr",null);// SpeechParts.Preposition
                    dict.Add("adv",null);// SpeechParts.Adverb
                    dict.Add("conj",null);// SpeechParts.Conjuction
                    dict.Add("intj",null);// SpeechParts.Interjection
                    dict.Add("num",null);//SpeechParts.Numeral
                    dict.Add("part",null);//SpeechParts.Part
                    dict.Add("s.prop",null);// SpeechParts.NounProp
                    dict.Add("advpro", null);
                    dict.Add("anum", null);
                    dict.Add("apro", null);

                    while (true)
                    {
                        line = reader.ReadLine();
                        if (line == null) break;

                        string[] res = line.Split('\t');

                        FrequencyDictionary.Item item = new FrequencyDictionary.Item();
                        item.Lemma = res[0];

                        item.freq = float.Parse(res[2]);
                        if (item.freq < 40) continue;

                        item.speechpart = dict[res[1].ToLower()];
                        if (item.speechpart == null) continue;
                        

                        items.Add(item);
                        //fd.Items.Add(item);
                    }
                    //DataBase.SaveChanges();                    

                }


                fd = new FrequencyDictionary();
                fd.Url = url;
                fd.Count = items.Count();
                DataBase.AddNewItemToDBContext(fd);

                // блок нужно переработать кривое использование id
                /*
                foreach(var grp in items.GroupBy(x => x.speechpart))
                {
                    FrequencyDictionary.RangeOfSpeechParts range = new FrequencyDictionary.RangeOfSpeechParts();
                    range.speechpart = grp.Key;
                    range.Count = grp.Count();
                    fd.Range.Add(range);

                    FrequencyDictionary.Item first = null;

                    var list2 = grp.OrderByDescending(x => x.freq);
                    foreach(var elm in list2)
                    {
                        fd.Items.Add(elm);
                        if (first == null) first = elm;
                    }
                    DataBase.SaveChanges();
                    range.StartId = first.id;
                    if (fd.StartId == 0) fd.StartId = first.id;
                }
                */

                DataBase.SaveChanges();
                //var lst = items.OrderBy(x => x.speechpart).Select(x=>x.speechpart);
                /*
                int id_ = 1;
                SpeechParts CurSpeechPart = null;
                foreach(var elm in lst)
                {
                    if()
                }
                */
            }
        }