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 Insert(SpellVM Spelling) { if (Spellings.Any(s => s.Text == Spelling.Text)) { var old_Spell = Spellings.First(s => s.Text == Spelling.Text); var old_score = ScoreHelper.GetScoreFromImportance(old_Spell.Importance); var new_score = ScoreHelper.GetScoreFromImportance(Spelling.Importance); if (new_score > old_score) { var to_update = new SpellVM(old_Spell.Id, old_Spell.Text, Spelling.Importance, old_Spell.IsActive); return(Update(to_update)); } else { return(Errors.ThrowErrorMsg(ErrorType.AlreadyInserted, Spelling.Text)); } } if (!ValidWordsAndAnswerSize(Spelling.Text)) { return(false); } if (!InsertSpelling(Spelling.ToModel())) { return(false); } Spelling.LoadCrossData(); return(true); }
public static bool Insert(VocVM Vocabulary) { if (Vocabularies.Any(s => s.Text == Vocabulary.Text)) { var old_Voc = Vocabularies.First(s => s.Text == Vocabulary.Text); var old_score = ScoreHelper.GetScoreFromImportance(old_Voc.Importance); var new_score = ScoreHelper.GetScoreFromImportance(Vocabulary.Importance); if (new_score > old_score) { var to_update = new VocVM(old_Voc.Id, old_Voc.Text, old_Voc.Answer, old_Voc.Definition, old_Voc.PtBr, Vocabulary.Importance, old_Voc.IsActive); return(Update(to_update)); } else { return(Errors.ThrowErrorMsg(ErrorType.AlreadyInserted, Vocabulary.Text)); } } if (!ValidWordsAndAnswerSize(Vocabulary.Text, Vocabulary.Answer)) { return(false); } if (!InsertVocabulary(Vocabulary.ToModel())) { return(false); } Vocabulary.LoadCrossData(); return(true); }
private void LoadChanceToAppear() { // peso 2 var daysSince = LastTry != null?DateTime.Now.Subtract(LastTry.When).Days : 100; var lastTry_score = 0; if (daysSince < 20 && daysSince >= 1) { lastTry_score = daysSince / 2; } else if (daysSince == 0) { Chance = 1; Chance_toolTip = "Question already completed today."; return; } else { lastTry_score = 20; } // peso 4 var inv_avg = 40.0; if (daysSince <= 7) { inv_avg -= ((20 * Avg_week) / 100) + ((15 * Avg_month) / 100) + ((05 * Avg_all) / 100); } else if (daysSince <= 30) { inv_avg -= ((30 * Avg_month) / 100) + ((10 * Avg_all) / 100); } else if (daysSince <= 7) { inv_avg -= ((40 * Avg_all) / 100); } // peso 1 var lastWasWrong = Tries != null && Tries.Any() ? (LastTry.Score == 100 ? 0 : 10) : 10; // peso 3 var imp_score = ScoreHelper.GetScoreFromImportance(Importance) * 3; Chance = Math.Round(lastTry_score + inv_avg + lastWasWrong + imp_score, 2); Chance_toolTip = inv_avg + " (inv_avg) -> " + (daysSince <= 7 ? "avg_week (20%) + avg_month (15%) + avg_all (5%)" : (daysSince <= 30 ? "avg_month (30%) + avg_all (10%)" : "avg_all (40%) + ")) + "\n"; Chance_toolTip += lastTry_score + " (lastTry) + " + lastWasWrong + " (lastWrong) + " + imp_score + " (imp)"; }