Ejemplo n.º 1
0
        public MainVM()
        {
            var initfaculty = XML.ReadFaculty(Path.FacultyXml);

            cfaculty = new ObservableCollection <Faculty>(initfaculty);

            var initclassroom = XML.ReadClassroom(Path.ClassroomXml);

            cclassroom = new ObservableCollection <ClassRoom>(initclassroom);

            var initdepartment = XML.ReadDepartment(Path.DepartmentXml);

            cdepartment = new ObservableCollection <Department>(initdepartment);

            var initgroup = XML.ReadGroup(Path.GroupXml);

            cgroup = new ObservableCollection <Group>(initgroup);

            var initteacher = XML.ReadTeacher(Path.TeacherXml);

            cteacher = new ObservableCollection <Teacher>(initteacher);

            var initsubject = XML.ReadSubject(Path.SubjectXml);

            csubject = new ObservableCollection <Subject>(initsubject);

            windowGroupVM      = new WindowGroupVM(cgroup, cdepartment);
            windowFacultyVM    = new WindowFacultyVM(cfaculty);
            windowClassroomVM  = new WindowClassroomVM(cclassroom, cdepartment);
            windowDepartmentVM = new WindowDepartmentVM(cdepartment, cfaculty);
            windowTeacherVM    = new WindowTeacherVM(cteacher, cdepartment);
            windowSubjectVM    = new WindowSubjectVM(csubject, cdepartment);

            createCommand = this.Factory.CommandSync(Create);
            openCommand   = this.Factory.CommandSync(Open);
            saveCommand   = this.Factory.CommandSync(Save);

            addFaculty    = this.Factory.CommandSync(AFaculty);
            addDepartment = this.Factory.CommandSync(ADepartment);
            addTeacher    = this.Factory.CommandSync(ATeacher);
            addGroup      = this.Factory.CommandSync(AGroup);
            addClassRoom  = this.Factory.CommandSync(AClassRoom);
            addSubject    = this.Factory.CommandSync(ASubject);

            closeWinCommand = this.Factory.CommandSync(Close);
        }
Ejemplo n.º 2
0
        public MainVM()
        {
            lday = new List <DayOfWeek>();
            lday.Add(DayOfWeek.Monday);
            lday.Add(DayOfWeek.Tuesday);
            lday.Add(DayOfWeek.Wednesday);
            lday.Add(DayOfWeek.Thursday);
            lday.Add(DayOfWeek.Friday);
            lday.Add(DayOfWeek.Saturday);

            var initfaculty = RequestToDataBase.Instance.ReadFaculty();

            cfaculty = new ObservableCollection <Faculty>(initfaculty);

            var initclassroom = RequestToDataBase.Instance.ReadClassrooms();

            cclassroom = new ObservableCollection <ClassRoom>(initclassroom);

            var initdepartment = RequestToDataBase.Instance.ReadDepartments();

            cdepartment = new ObservableCollection <Department>(initdepartment);

            var initgroup = RequestToDataBase.Instance.ReadGroups();

            cgroup = new ObservableCollection <Group>(initgroup);

            var initteacher = RequestToDataBase.Instance.ReadTeachers();

            cteacher = new ObservableCollection <Teacher>(initteacher);

            var initsubject = RequestToDataBase.Instance.ReadSubjects();

            csubject = new ObservableCollection <Subject>(initsubject);

            var initlistsubjects = RequestToDataBase.Instance.ReadSubjects();

            lsubject = new List <Subject>(initlistsubjects);

            var tands = RequestToDataBase.Instance.ReadTeacherAndSubjects();
            var dct   = tands.ToDictionary(t => (t.Teacher.CodeOfTeacher, t.Teacher.Department.CodeOfDepartment), t => t);
            var all   = cteacher.Select(t => dct.TryGetValue((t.CodeOfTeacher, t.Department.CodeOfDepartment), out TeachersAndSubjects tsv) ? tsv : CreateTeacherAndSubjects(t));

            allTeachersAndSubjects = new ObservableCollection <TeachersAndSubjects>(all);

            var gands     = RequestToDataBase.Instance.ReadGroupsAndSubjects();
            var dctGroup  = gands.ToDictionary(g => g.Group.CodeOfGroup, g => g);
            var allGroups = cgroup.Select(g => dctGroup.TryGetValue(g.CodeOfGroup, out GroupsAndSubjects gs) ? gs : CreateEmptyGroupsAndSubjects(g));

            groupsAndSubjects = new ObservableCollection <GroupsAndSubjects>(allGroups);

            windowGroupVM               = new WindowGroupVM(cgroup, cdepartment);
            windowFacultyVM             = new WindowFacultyVM(cfaculty);
            windowClassroomVM           = new WindowClassroomVM(cclassroom, cdepartment);
            windowDepartmentVM          = new WindowDepartmentVM(cdepartment, cfaculty);
            windowTeacherVM             = new WindowTeacherVM(cteacher, cdepartment);
            windowSubjectVM             = new WindowSubjectVM(csubject, cdepartment);
            windowTeachersAndSubjectsVM = new WindowTeachersAndSubjectsVM(cteacher, allTeachersAndSubjects, lsubject, lday);
            windowGroupsAndSubjectsVM   = new WindowGroupsAndSubjectsVM(cgroup, groupsAndSubjects, csubject);

            createCommand = this.Factory.CommandSync(Create);
            openCommand   = this.Factory.CommandSync(Open);
            saveCommand   = this.Factory.CommandSync(Save);

            addFaculty             = this.Factory.CommandSync(AFaculty);
            addDepartment          = this.Factory.CommandSync(ADepartment);
            addTeacher             = this.Factory.CommandSync(ATeacher);
            addGroup               = this.Factory.CommandSync(AGroup);
            addClassRoom           = this.Factory.CommandSync(AClassRoom);
            addSubject             = this.Factory.CommandSync(ASubject);
            addTeachersAndSubjects = this.Factory.CommandSync(ATeachersAndSubjects);
            addGroupsAndSubjects   = this.Factory.CommandSync(AGroupsAndSubjects);
            closeWinCommand        = this.Factory.CommandSync(Close);
        }