예제 #1
0
 public void AddFutureTest(Test test)
 {
     configRoot.Value = (int.Parse(configRoot.Value) + 1).ToString();
     configRoot.Save(Configuration.FILE_CONFIG);
     DataSource.tests.Add(test);
     Xml_files.SaveToXML(DataSource.tests, Configuration.FILE_TESTS);
 }
예제 #2
0
        /// <summary>
        /// constracor of this Dal. bring the data from the DB (xml) to the Lists.
        /// </summary>

        public imp_XML_Dal()
        {
            if (!File.Exists(Configuration.FILE_USERS))
            {
                CreateUsersFiles();
            }
            else
            {
                LoadUsersData();
            }
            if (!File.Exists(Configuration.FILE_CONFIG))
            {
                CreateConfigFiles();
            }
            else
            {
                LoadConfigData();
            }
            if (File.Exists(Configuration.FILE_TESTERS) && File.ReadLines(Configuration.FILE_TESTERS).Count() > 2)
            {
                DataSource.testers = Xml_files.LoadFromXML <List <Tester> >(Configuration.FILE_TESTERS);
            }
            if (File.Exists(Configuration.FILE_TESTS) && File.ReadLines(Configuration.FILE_TESTS).Count() > 2)
            {
                DataSource.tests = Xml_files.LoadFromXML <List <Test> >(Configuration.FILE_TESTS);
            }
            if (File.Exists(Configuration.FILE_TRAINEES) && File.ReadLines(Configuration.FILE_TRAINEES).Count() > 2)
            {
                DataSource.trainees = Xml_files.LoadFromXML <List <Trainee> >(Configuration.FILE_TRAINEES);
            }
        }
예제 #3
0
 public void deleteTest(int id)
 {
     if (GetTestByNumber(id) == null)
     {
         throw new Exception(string.Format("test {0} not exist", id));
     }
     DS.DataSource.tests.RemoveAll(test => test.TestNumber == id);
     Xml_files.SaveToXML(DataSource.tests, Configuration.FILE_TESTS);
 }
예제 #4
0
 public void AddTester(Tester tester)
 {
     if (DS.DataSource.testers.Any(item => item.Id == tester.Id))
     {
         throw new Exception("The tester already exists!");
     }
     DS.DataSource.testers.Add(tester);
     Xml_files.SaveToXML(DataSource.testers, Configuration.FILE_TESTERS);
 }
예제 #5
0
 public void AddTrainee(Trainee trainee)
 {
     if (DS.DataSource.trainees.Any(item => item.Id == trainee.Id))
     {
         throw new Exception("The tester you attempted to delete has tests scheduled. please make sure the tester is free before deleting!");
     }
     DS.DataSource.trainees.Add(trainee);
     Xml_files.SaveToXML(DataSource.trainees, Configuration.FILE_TRAINEES);
 }
예제 #6
0
        public void UpdateTester(int id, Tester tester)
        {
            int before = DS.DataSource.testers.Count();

            DS.DataSource.testers = new List <Tester>(from tester1 in DS.DataSource.testers where id != tester1.Id select tester1);
            if (before == DS.DataSource.testers.Count())
            {
                throw new Exception($"Wasnn't able to remove {tester.ToString()}");
            }
            DS.DataSource.testers.Add(tester);
            Xml_files.SaveToXML(DataSource.testers, Configuration.FILE_TESTERS);
        }
예제 #7
0
        public void UpdateTrainee(int id, Trainee trainee)
        {
            Trainee trainee_old = GetTraineeById(trainee.Id);

            if (trainee_old == null)
            {
                throw new Exception(string.Format("not found trainee {0}", trainee.Id));
            }
            DS.DataSource.trainees.RemoveAll(t => t.Id == id);
            DS.DataSource.trainees.Add(trainee);
            Xml_files.SaveToXML(DataSource.trainees, Configuration.FILE_TRAINEES);
        }
예제 #8
0
 public void DeleteTester(int id)
 {
     if (DS.DataSource.tests.Any((test) => test.TesterId == id))
     {
         throw new Exception("The tester you attempted to delete has tests scheduled. please make sure the tester is free before deleting!");
     }
     DS.DataSource.testers.RemoveAll(tester => tester.Id == id);
     if (!DS.DataSource.testers.Any(tester => tester.Id == id))
     {
         throw new Exception("Attempted to delete an unexistent tester");
     }
     Xml_files.SaveToXML(DataSource.testers, Configuration.FILE_TESTERS);
 }
예제 #9
0
 public void DeleteTrainee(int id)
 {
     if (DS.DataSource.tests.Any(item => item.TraineeId == id))
     {
         throw new Exception("The trainee you attempted to delete has tests scheduled. please make sure the trainee is free before deleting!");
     }
     if (!DS.DataSource.trainees.Any(item => item.Id == id))
     {
         throw new Exception("Attempted to delete an unexistent trainee");
     }
     DS.DataSource.trainees.RemoveAll(item => item.Id == id);
     Xml_files.SaveToXML(DataSource.trainees, Configuration.FILE_TRAINEES);
 }
예제 #10
0
        public void FinishTest(int id, CriterionsOfTest criterions, bool pass, string note)
        {
            Test test = GetTestByNumber(id);

            if (test == null)
            {
                throw new Exception("Attempted to finish an unexistent test");
            }
            test.Criterions = criterions ?? throw new Exception("You have to insert criterions to finish test");
            test.Pass       = pass;
            test.TesterNote = note;
            DataSource.tests.RemoveAll(t => t.TestNumber == id);
            DataSource.tests.Add(test);
            Xml_files.SaveToXML(DataSource.tests, Configuration.FILE_TESTS);
        }