public static bool Insert(PronVM Pronunciation) { if (Pronunciations.Any(s => s.Text == Pronunciation.Text)) { var old_Pron = Pronunciations.First(s => s.Text == Pronunciation.Text); var old_score = ScoreHelper.GetScoreFromImportance(old_Pron.Importance); var new_score = ScoreHelper.GetScoreFromImportance(Pronunciation.Importance); if (new_score > old_score) { var to_update = new PronVM(old_Pron.Id, old_Pron.Text, old_Pron.Phonemes, Pronunciation.Importance, old_Pron.IsActive); return(Update(to_update)); } else { return(Errors.ThrowErrorMsg(ErrorType.AlreadyInserted, Pronunciation.Text)); } } if (!InsertPronunciation(Pronunciation.ToModel())) { return(false); } Pronunciation.LoadCrossData(); return(true); }
public static bool Remove(PronVM Pronunciation) { if (!RemovePronunciation(Pronunciation)) { return(false); } return(true); }
public static bool Update(PronVM Pronunciation) { if (!UpdatePronunciation(Pronunciation.ToModel())) { return(false); } var oldVM = Pronunciations.FindIndex(x => x.Id == Pronunciation.Id); Pronunciations.Insert(oldVM, Pronunciation); return(true); }
public static void AddIntoThis(PronVM Pron, StackPanel item_line) { var row1 = MyGrids.GetRowItem(new List <int>() { 3, 3, 3, 2, 1, 1, 1 }, item_line); var wpf = new PronWpfItem(); MyTxts.Get(wpf.Words, 0, 0, row1, Pron.Text); wpf.Words.ToolTip = "Id " + Pron.Id; MyTxts.Get(wpf.Phonemes, 0, 1, row1, Pron.Phonemes); MyCbBxs.Importance(wpf.Imp, 0, 2, row1, Pron.Importance, false); MyLbls.Chance(wpf.Chance, 0, 3, row1, Pron); MyBtns.Is_active(wpf.IsActive, 0, 4, row1, Pron.IsActive); MyBtns.Quest_Edit(wpf.Edit, 0, 5, row1, Pron, wpf, item_line); MyBtns.Remove_quest(wpf.Remove, 0, 6, row1, Pron, item_line); }
public static void AddIntoItems(StackPanel stack_items, PronVM Pron, bool isNew) { var item_line = MyStacks.GetItemLine(stack_items, isNew); AddIntoThis(Pron, item_line); }