public void RemoveTest(Test toRemove) { DataSource.testList.RemoveAll(T => T.TestNumber == toRemove.TestNumber); XMLHandler.GetXMLHandler().SaveToXML(DataSource.testList, XMLHandler.GetXMLHandler().TestPath); }
public void AddTest(Test test) { DataSource.testList.Add(test); XMLHandler.GetXMLHandler().SaveToXML(DataSource.testList, XMLHandler.GetXMLHandler().TestPath); }
public static Test DeepClone(this Test t) { return(new Test(t, (bool)t.DistanceKeep, (bool)t.ReverseParking, (bool)t.Parking, (bool)t.LookingAtMirrors, (bool)t.Junction, (bool)t.Reversing, (bool)t.Roundabout, (bool)t.Overtaking, (bool)t.Turning, t.TesterNote, (bool)t.Grade)); }
public void updateTestDetails(Test T) { }
public void removeTest(Test T) { }
public void addTest(Test T) { ; }
public Test GetAllTestById(int testId) { using (SqlConnection connection = new SqlConnection(_connectionString)) { var command = connection.CreateCommand(); command.CommandType = CommandType.StoredProcedure; command.CommandText = "dbo.GetAllTestById"; command.Parameters.AddWithValue("@id", testId); connection.Open(); try { var reader = command.ExecuteReader(); Test test = null; Dictionary <int, Question> questions = new Dictionary <int, Question>(); while (reader.Read()) { if (test == null) { test = new Test() { ID = (int)reader["testId"], Description = reader["description"] as string, Time = (int)reader["time"], Category = new Category() { ID = (int)reader["id_Category"] }, Subject = new Subject() { ID = (int)reader["id_Subject"] } }; } Question questionFromRequest = new Question() { ID = (int)reader["idQuestion"], Text = reader["textQuestion"] as string, Image = reader["imageQuestion"] == DBNull.Value ? null : Convert.FromBase64String((string)reader["imageQuestion"]) }; Answer answer = new Answer() { ID = (int)reader["idAnswer"], AnswerText = reader["textAnswer"] as string, IsCorrect = (bool)reader["IsCorrectAnswer"] }; if (questions.TryGetValue((int)reader["idQuestion"], out Question question)) { question.Answers.Add(answer); } else { questions.Add((int)reader["idQuestion"], questionFromRequest); questionFromRequest.Answers.Add(answer); } } test.Questions = questions.Select(kvp => kvp.Value).ToList();; return(test); } catch (SqlException e) { _log.Error(e.Message); throw e; } } }