protected static bool RemoveQuestionAttempt(AttemptVM att) { string query = string.Format(RemoveSQL, GetDBAttemptName(att.Type), att.Id); if (!SendQuery(query)) { return(false); } if (att.Type == Model.Voc) { VocabularyAttempts.Remove(att); } else if (att.Type == Model.Spell) { SpellingAttempts.Remove(att); } return(true); }
protected static bool InsertAttempt(AttemptVM att) { string query = string.Format(InsertSQL + "'{1}', '{2}', '{3}')", GetDBAttemptName(att.Type), att.IdQuestion, att.Score, att.When); if (!SendQuery(query)) { return(false); } var inserted = GetLast(GetDBAttemptName(att.Type)); if (att.Type == Model.Voc) { if (VocabularyAttempts == null) { VocabularyAttempts = new List <AttemptVM>(); } VocabularyAttempts.Add(inserted.Tables[0].AsEnumerable(). Select(GetDatarowAttempts(att.Type)).First()); } else if (att.Type == Model.Essay) { if (EssayAttempts == null) { EssayAttempts = new List <AttemptVM>(); } EssayAttempts.Add(inserted.Tables[0].AsEnumerable(). Select(GetDatarowAttempts(att.Type)).First()); } else if (att.Type == Model.SumRetell) { if (SumRetellAttempts == null) { SumRetellAttempts = new List <AttemptVM>(); } SumRetellAttempts.Add(inserted.Tables[0].AsEnumerable(). Select(GetDatarowAttempts(att.Type)).First()); } else if (att.Type == Model.DescImg) { if (DescImgAttempts == null) { DescImgAttempts = new List <AttemptVM>(); } DescImgAttempts.Add(inserted.Tables[0].AsEnumerable(). Select(GetDatarowAttempts(att.Type)).First()); } if (att.Type == Model.Spell) { if (SpellingAttempts == null) { SpellingAttempts = new List <AttemptVM>(); } SpellingAttempts.Add(inserted.Tables[0].AsEnumerable(). Select(GetDatarowAttempts(att.Type)).First()); } return(true); }