public IList <Question> GetQuestions() { DatabaseService databaseService = DatabaseService.GetInstance(); ExamDatabaseWorker databaseWorker = databaseService.ExamDatabaseWorker; try { if (id == null) { return(null); } if (databaseWorker != null) { databaseWorker.Unload(); Question[] result = databaseWorker.GetQuestions(id.Value); return(result.ToList()); } else { LastExceptionMessage = "Подкючение к базе данных не установлено."; return(null); } } catch (Exception ex) { LastExceptionMessage = ex.Message; return(null); } }
public bool Save(Exam exam) { DatabaseService databaseService = DatabaseService.GetInstance(); ExamDatabaseWorker databaseWorker = databaseService.ExamDatabaseWorker; try { if (databaseWorker != null) { if (id == null) { databaseWorker.Unload(); } if (id != null) { databaseWorker.DeleteExam(id.Value); } id = databaseWorker.SaveExam(exam); SaverName = exam.Name; return(true); } else { LastExceptionMessage = "Подкючение к базе данных не установлено."; return(false); } } catch (Exception ex) { LastExceptionMessage = ex.Message; return(false); } }
public Exam GetExam() { DatabaseService databaseService = DatabaseService.GetInstance(); ExamDatabaseWorker databaseWorker = databaseService.ExamDatabaseWorker; try { if (id == null) { return(null); } if (databaseWorker != null) { databaseWorker.Unload(); Exam result = databaseWorker.GetExam(id.Value); SaverName = result.Name; return(result); } else { LastExceptionMessage = "Подкючение к базе данных не установлено."; return(null); } } catch (Exception ex) { LastExceptionMessage = ex.Message; return(null); } }