示例#1
0
        public void loadAllTestContentFromBD(int testId)
        {
            Subject newSubject = new Subject();

            newSubject.Id = DataSetConverter.fromDsToSingle.toInt.
                            convert(SqlLiteSimpleExecute.execute(queryConfigurator.loadSubjectId(testId)));
            Test loadTest = testManipulator.load(testId, true, false);

            loadTest.IsSelected = true;

            bool testAlreadyPreLoad = false;
            int  subjectPosition    = -1;

            for (int i = 0; i < store.Count; i++)
            {
                if (store.ElementAt(i).Id == newSubject.Id)
                {
                    testAlreadyPreLoad = true;
                    subjectPosition    = i;
                    break;
                }
            }

            if (!testAlreadyPreLoad)
            {
                List <Subject> newConfig = new List <Subject>();
                newSubject.Tests.Add(loadTest);
                newSubject.Name = DataSetConverter.fromDsToSingle.toString.
                                  convert(SqlLiteSimpleExecute.execute(queryConfigurator.
                                                                       loadSubjectName(newSubject.Id)));
                newConfig.Add(newSubject);
                setConfig(newConfig);
            }
            else
            {
                for (int i = 0; i < config.ElementAt(subjectPosition).Tests.Count; i++)
                {
                    if (config.ElementAt(subjectPosition).Tests.ElementAt(i).Id == testId)
                    {
                        config.ElementAt(subjectPosition).Tests.RemoveAt(i);
                        config.ElementAt(subjectPosition).Tests.Insert(i, loadTest);
                        setConfig(config);
                        break;
                    }
                }
            }

            loadStore();
        }