Beispiel #1
0
        public void initData()
        {
            //Confirmation all teachers, grades and classes have loaded.
            if (!ClassViewModel.getInstance().mIsInitialized)
            {
                ClassViewModel.getInstance().worker_initData();
            }
            //confirmation all course groups and locations has loaded.
            if (!CourseWeekViewModel.getInstance().mIsInitialized)
            {
                CourseWeekViewModel.getInstance().worker_initDataFromDatabase(false);
            }

            //Get the current user's id.
            MemberBasic currentUser = (MemberBasic)Application.Current.Properties["currentUser"];
            int         basicid     = 0;

            if (currentUser != null)
            {
                basicid = currentUser.id;
            }
            selectedClassid = DatabaseHelper.getClassIdByHeadTeacherId(basicid);
            classCourses    = DatabaseHelper.getClassCoursesByTeacherId(basicid);

            //find the class which the teacher has teached.
            foreach (ClassCourse cc in classCourses)
            {
                classes.Add(ClassViewModel.getInstance().getClassById(cc.classid));
            }
            courseGroups     = getCourseGroupsByClassId(selectedClassid);
            selectedCourseid = courseGroups[0].id;

            //start load  course cards.
            currentCourseCards = DatabaseHelper.getAllCourseCards(selectedClassid, selectedCourseid);
        }
Beispiel #2
0
        public ObservableCollection <CourseGroup> getCourseGroupsByClassId(int classid)
        {
            ObservableCollection <CourseGroup> courseGroupsByClassid = new ObservableCollection <CourseGroup>();
            string coursegroupsids = "";

            foreach (ClassCourse cc in classCourses)
            {
                if (cc.classid == classid)
                {
                    coursegroupsids = cc.coursesid; break;
                }
            }

            if (!coursegroupsids.Equals(""))
            {
                // start to handle the string.
                string[] ids = coursegroupsids.Split('|');
                foreach (string id in ids)
                {
                    int coursegroupid = Int32.Parse(id);
                    courseGroupsByClassid.Add(CourseWeekViewModel.getInstance().getCourseGroupById(coursegroupid));
                }
            }

            return(courseGroupsByClassid);
        }
 public static CourseWeekViewModel getInstance()
 {
     // DoubleLock
     if (instance == null)
     {
         lock (m_lock)
         {
             if (instance == null)
             {
                 instance = new CourseWeekViewModel();
             }
         }
     }
     return(instance);
 }