public static KanjiModel SelectTargetKanji(KanjiListModel shortList) { Random r = new Random(); KanjiModel target = shortList.Kanji[r.Next(shortList.Kanji.Count)]; return(target); }
public static string MeaningListToString(KanjiModel target) { string list = String.Empty; for (int i = 0; i < target.Meanings.Count; i++) { list += target.Meanings[i]; if (i < target.Meanings.Count - 1) { list += ", "; } } return(list); }
public override void LoadFull(JaviModel model) { if (!model.IsLoadFull) { using (var db = new JazeDatabaseContext()) { model.Means = JsonConvert.DeserializeObject <List <WordMean> >(model.MeanText); foreach (var mean in model.Means) { if (mean.ExampleIds != null) { mean.Examples = new List <ExampleModel>(); foreach (var exampleId in mean.ExampleIds) { var example = db.JaViExamples.Find(exampleId); if (example != null) { mean.Examples.Add(ExampleModel.Create(example)); } } } } //fetch kanji in word model.Kanjis = new List <KanjiModel>(); var kanjis = StringUtil.FilterCharsInString(model.Word, CharSet.Kanji); foreach (var c in kanjis) { var kanji = c.ToString(); var kanjiEntity = db.Kanjis.FirstOrDefault(e => e.Word == kanji); if (kanjiEntity != null) { model.Kanjis.Add(KanjiModel.Create(kanjiEntity)); } else { model.Kanjis.Add(new KanjiModel { Word = kanji }); } } model.IsLoadFull = true; } } }