예제 #1
0
파일: Dal_XML_imp.cs 프로젝트: AviK311/WPF
 public void RemoveTest(Test toRemove)
 {
     DataSource.testList.RemoveAll(T => T.TestNumber == toRemove.TestNumber);
     XMLHandler.GetXMLHandler().SaveToXML(DataSource.testList, XMLHandler.GetXMLHandler().TestPath);
 }
예제 #2
0
파일: Dal_XML_imp.cs 프로젝트: AviK311/WPF
 public void AddTest(Test test)
 {
     DataSource.testList.Add(test);
     XMLHandler.GetXMLHandler().SaveToXML(DataSource.testList, XMLHandler.GetXMLHandler().TestPath);
 }
예제 #3
0
 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));
 }
예제 #4
0
 public void updateTestDetails(Test T)
 {
 }
예제 #5
0
 public void removeTest(Test T)
 {
 }
예제 #6
0
 public void addTest(Test T)
 {
     ;
 }
예제 #7
0
 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;
         }
     }
 }