예제 #1
0
        public AddStudentViewModel(AddStudentView view, Student editStudent, IEventAggregator eventAggr)
        {
            this.view        = view;
            this.editStudent = editStudent;
            this.eventAggr   = eventAggr;

            if (editStudent != null)
            {
                StudentName    = editStudent.NameAndSurname;
                StudyProgramId = editStudent.StudyProgramId;
                DepartmentId   = editStudent.DepartmentId;
                Address        = editStudent.Address;
                Phone          = editStudent.Phone;
                BirthPlace     = editStudent.BirthPlace;
                BirthDate      = editStudent.BirthDate;
                StudyYear      = editStudent.StudyYear;
                Balance        = editStudent.Balance;
                Username       = editStudent.Username;
                Password       = editStudent.Password;
            }

            StudyPrograms = new ObservableCollection <StudyProgram>(ServiceDataProvider.GetAllStudyPrograms());
            Departments   = ServiceDataProvider.GetAllDepartments();

            view.cbxDepartments.SelectionChanged += CbxDepartments_SelectionChanged;
        }
예제 #2
0
 public StudyProgramViewModel(IEventAggregator eventArggr)
 {
     this.eventArggr = eventArggr;
     StudyPrograms   = new ObservableCollection <StudyProgram>(ServiceDataProvider.GetAllStudyPrograms());
     ServiceDataProvider.AddStudyProgramNotification += ServiceDataProvider_AddStudyProgramNotification;
     SubscribeToParentTableNameChange(eventArggr);
 }
예제 #3
0
        public CourseViewModel(IEventAggregator eventAggregator)
        {
            this.eventAggregator = eventAggregator;

            Courses = new ObservableCollection <Course>(ServiceDataProvider.GetAllCourses());
            ServiceDataProvider.AddCourseNotification += ServiceDataProvider_AddCourseNotification;
            SubscribeToParentTableNameChange(eventAggregator);
        }
예제 #4
0
        public ExamViewModel(IEventAggregator eventAggregator)
        {
            this.eventAggregator = eventAggregator;

            Exams = new ObservableCollection <Exam>(ServiceDataProvider.GetAllExams());
            ServiceDataProvider.AddExamNotification += ServiceDataProvider_AddExamNotification;
            eventAggregator.GetEvent <ExamPeriodEvent>().Subscribe(p => SubcribeToParentTableNameChange(p));
            eventAggregator.GetEvent <CourseEvent>().Subscribe(p => SubcribeToParentTableNameChange(p));
        }
예제 #5
0
        private void ExecuteRemove(object p)
        {
            if (p != null && p is Course)
            {
                var course = p as Course;

                ServiceDataProvider.DeleteCourse(course.CourseId);
                Courses.Remove(course);
            }
        }
예제 #6
0
        private void ExecuteRemove(object p)
        {
            if (p != null && p is Exam)
            {
                var exam = p as Exam;

                ServiceDataProvider.DeleteExam(exam.ExamId);
                Exams.Remove(exam);
            }
        }
예제 #7
0
        private void ExecuteRemove(object p)
        {
            if (p != null && p is Student)
            {
                var student = p as Student;

                ServiceDataProvider.DeleteStudent(student.StudentId);
                Students.Remove(student);
            }
        }
예제 #8
0
        private void ExecuteSave(object param)
        {
            try
            {
                if (editStudent != null)
                {
                    editStudent.NameAndSurname   = StudentName;
                    editStudent.StudyProgramId   = StudyProgramId;
                    editStudent.StudyProgramName = view.cbxStudyPrograms.Text;
                    editStudent.DepartmentId     = DepartmentId;
                    editStudent.DepartmentName   = view.cbxDepartments.Text;
                    editStudent.Address          = Address;
                    editStudent.Balance          = Balance;
                    editStudent.BirthDate        = BirthDate;
                    editStudent.BirthPlace       = BirthPlace;
                    editStudent.StudyYear        = StudyYear;
                    editStudent.Phone            = Phone;
                    editStudent.Username         = Username;
                    editStudent.Password         = Password;

                    ServiceDataProvider.EditStudent(editStudent);
                    eventAggr.GetEvent <StudentEvent>().Publish(editStudent);
                }
                else
                {
                    Student newStudent = new Student()
                    {
                        NameAndSurname = StudentName,
                        StudyProgramId = StudyProgramId,
                        DepartmentId   = DepartmentId,
                        Address        = Address,
                        Balance        = Balance,
                        BirthDate      = BirthDate,
                        BirthPlace     = BirthPlace,
                        Phone          = Phone,
                        StudyYear      = StudyYear,
                        Username       = Username,
                        Password       = Password,
                    };

                    ServiceDataProvider.AddStudent(newStudent);
                }
            }
            catch (Exception e)
            {
                e.Message.ToString();
            }
            finally
            {
                view.Close();
            }
        }
예제 #9
0
 private void ExecuteConfirmResults(object p)
 {
     try
     {
         if (ServiceDataProvider.SetExamResults(resultModels))
         {
             MessageBox.Show(string.Format("Exam results are stored in database"));
         }
     }
     catch (FaultException fe)
     {
         MessageBox.Show(string.Format("Error occured during transaction! Details: {0}", fe.Message));
     }
 }
예제 #10
0
        private void ExecuteSave(object p)
        {
            try
            {
                if (!ServiceDataProvider.ValidateExamPeriodActivity(StartDate.Value))
                {
                    MessageBox.Show("Active Exam Period already exists in defined period!", "Exam Period Validation",
                                    MessageBoxButton.OK, MessageBoxImage.Warning);

                    return;
                }

                if (editExamPeriod != null)
                {
                    editExamPeriod.Name        = Name;
                    editExamPeriod.StartDate   = StartDate.Value;
                    editExamPeriod.EndDate     = EndDate.Value;
                    editExamPeriod.SchoolYear  = SchoolYear;
                    editExamPeriod.IsActive    = IsActive;
                    editExamPeriod.IsApsolvent = IsApsolvent;

                    ServiceDataProvider.EditExamPeriod(editExamPeriod);
                    eventAggregator.GetEvent <ExamPeriodEvent>().Publish(editExamPeriod);
                }
                else
                {
                    ExamPeriod ep = new ExamPeriod()
                    {
                        Name        = Name,
                        StartDate   = StartDate.Value,
                        EndDate     = EndDate.Value,
                        SchoolYear  = SchoolYear,
                        IsActive    = IsActive,
                        IsApsolvent = IsApsolvent
                    };

                    ServiceDataProvider.AddExamPeriod(ep);
                }
            }
            catch (Exception ex)
            {
                ex.Message.ToString();
            }
            finally
            {
                view.Close();
            }
        }
예제 #11
0
        private void ExecuteSave(object p)
        {
            try
            {
                if (!ServiceDataProvider.ValidateExamInExamPeriod(ExamPeriodId, CourseId))
                {
                    MessageBox.Show("Exam for Course already exists in Exam Period!", "Exam Validation",
                                    MessageBoxButton.OK, MessageBoxImage.Warning);

                    return;
                }

                if (editExam != null)
                {
                    editExam.ExamPeriodId = ExamPeriodId;
                    editExam.CourseId     = CourseId;
                    editExam.DateAndTime  = DateAndTime.Value;
                    editExam.Place        = Place;
                    editExam.Price        = Price;
                    editExam.IsPassed     = IsPassed;

                    ServiceDataProvider.EditExam(editExam);
                }
                else
                {
                    Exam exam = new Exam()
                    {
                        ExamPeriodId = ExamPeriodId,
                        CourseId     = CourseId,
                        DateAndTime  = DateAndTime.Value,
                        Place        = Place,
                        Price        = Price,
                        IsPassed     = IsPassed
                    };

                    ServiceDataProvider.AddExam(exam);
                }
            }
            catch (Exception ex)
            {
                ex.Message.ToString();
            }
            finally
            {
                view.Close();
            }
        }
예제 #12
0
        public AddStudyProgramViewModel(AddStudyProgramView view, StudyProgram editSP, IEventAggregator eventArgs)
        {
            this.editSP    = editSP;
            this.view      = view;
            this.eventArgs = eventArgs;

            Departments = new ObservableCollection <Department>(ServiceDataProvider.GetAllDepartments());

            if (editSP != null)
            {
                Name               = editSP.Name;
                DepartmentId       = editSP.DepartmentId;
                SelffinancedPlaces = editSP.SelffinancedPlaces;
                BudgetPlaces       = editSP.BudgetPlaces;
                Tuition            = editSP.Tuition;
            }
        }
예제 #13
0
        private void ExecuteRemove(object p)
        {
            if (p != null && p is Professor)
            {
                try
                {
                    var professor = p as Professor;

                    ServiceDataProvider.DeleteProfessor(professor.ProfessorId);
                    Professors.Remove(professor);
                }
                catch (FaultException <DeleteFault> fe)
                {
                    MessageBox.Show(string.Format("{0} {1}", fe.Detail.Message, fe.Detail.Description));
                }
            }
        }
예제 #14
0
        private void ExecuteRemove(object p)
        {
            if (p != null && p is StudyProgram)
            {
                try
                {
                    var studyProgram = p as StudyProgram;

                    ServiceDataProvider.DeleteStudyProgram(studyProgram.StudyProgramId);
                    StudyPrograms.Remove(studyProgram);
                }
                catch (FaultException <DeleteFault> fe)
                {
                    MessageBox.Show(string.Format("{0} {1}", fe.Detail.Message, fe.Detail.Description));
                }
            }
        }
예제 #15
0
        private void ExecuteRemove(object p)
        {
            if (p != null && p is ExamPeriod)
            {
                try
                {
                    var examPeriod = p as ExamPeriod;

                    ServiceDataProvider.DeleteExamPeriod(examPeriod.ExamPeriodId);
                    ExamPeriods.Remove(examPeriod);
                }
                catch (FaultException <DeleteFault> fe)
                {
                    MessageBox.Show(string.Format("{0} {1}", fe.Detail.Message, fe.Detail.Description));
                }
            }
        }
예제 #16
0
        private void ExecuteSave(object param)
        {
            try
            {
                if (editProf != null)
                {
                    editProf.NameAndSurname = NameAndSurname;
                    editProf.IsAdmin        = IsAdmin;
                    editProf.Phone          = Phone;
                    editProf.Address        = Address;
                    editProf.BirthDate      = BirthDate;
                    editProf.BirthPlace     = BirthPlace;
                    editProf.Education      = Education;
                    editProf.Username       = Username;
                    editProf.Password       = Password;

                    ServiceDataProvider.EditProfessor(editProf);
                    eventAggregator.GetEvent <ProfessorEvent>().Publish(editProf);
                }
                else
                {
                    Professor p = new Professor()
                    {
                        NameAndSurname = NameAndSurname,
                        IsAdmin        = IsAdmin,
                        Address        = Address,
                        Phone          = Phone,
                        BirthDate      = BirthDate,
                        BirthPlace     = BirthPlace,
                        Education      = Education,
                        Username       = Username,
                        Password       = Password
                    };

                    ServiceDataProvider.AddProfessor(p);
                }
            }
            catch (Exception e)
            {
                e.Message.ToString();
            }
            finally
            {
                view.Close();
            }
        }
예제 #17
0
        private void ExecuteRemove(object p)
        {
            if (p != null && p is Department)
            {
                try
                {
                    var department = p as Department;

                    ServiceDataProvider.DeleteDepartment(department.DepartmentId);
                    Departments.Remove(department);
                }
                catch (FaultException <DeleteFault> fe)
                {
                    MessageBox.Show(string.Format("{0} {1}", fe.Detail.Message, fe.Detail.Description));
                }
            }
        }
예제 #18
0
        private void ProvideRegistredStudentsAndExamInfo()
        {
            if (CourseId == 0)
            {
                return;
            }

            var regStudents = ServiceDataProvider.GetRegistredStudentsForExam(CourseId, GetExamPeriodIdFromTag());

            if (regStudents.Count == 1)
            {
                Students = new ObservableCollection <ExamRegistration>(regStudents.Keys.First());
                var examInfos = regStudents.Values.First();
                DateAndTime = (DateTime)examInfos[0];
                Place       = (string)examInfos[1];
            }
        }
예제 #19
0
        public AddExamViewModel(AddExamView view, Exam editExam)
        {
            this.view     = view;
            this.editExam = editExam;

            ExamPeriods = new ObservableCollection <ExamPeriod>(ServiceDataProvider.GetAllExamPeriods());
            Courses     = new ObservableCollection <Course>(ServiceDataProvider.GetAllCourses());

            if (editExam != null)
            {
                ExamPeriodId = editExam.ExamPeriodId;
                CourseId     = editExam.CourseId;
                DateAndTime  = editExam.DateAndTime;
                Place        = editExam.Place;
                Price        = editExam.Price;
                IsPassed     = editExam.IsPassed;
            }
        }
예제 #20
0
        public AddCourseViewModel(AddCourseView view, Course editCourse, IEventAggregator eventAggregator)
        {
            this.view            = view;
            this.editCourse      = editCourse;
            this.eventAggregator = eventAggregator;

            if (editCourse != null)
            {
                Name           = editCourse.Name;
                StudyProgramId = editCourse.StudyProgramId;
                ProfessorId    = editCourse.ProfessorId;
                Assistant      = editCourse.Assistant;
                ETCS           = editCourse.ETCS;
            }

            StudyPrograms = new ObservableCollection <StudyProgram>(ServiceDataProvider.GetAllStudyPrograms());
            Professors    = new ObservableCollection <Professor>(ServiceDataProvider.GetAllProfessors());
        }
예제 #21
0
        public MainViewViewModel(MainWindow view)
        {
            this.view = view;

            examPeriodTabs = new ObservableCollection <TabItem>();

            foreach (var activeExamPeriod in ServiceDataProvider.GetActiveExamPeriods())
            {
                examPeriodTabs.Add(new TabItem()
                {
                    Header = activeExamPeriod.Name, Tag = activeExamPeriod.ExamPeriodId
                });
            }

            Courses  = ServiceDataProvider.GetProfessorCourses(4);
            students = new ObservableCollection <ExamRegistration>();
            view.Tabcontrol.SelectedIndex     = 0;
            view.cbxCourses.SelectedIndex     = 0;
            view.OnSelectionComboBoxChanged   = delegate { ProvideRegistredStudentsAndExamInfo(); };
            view.OnSelectionTabControlChanged = delegate { ProvideRegistredStudentsAndExamInfo(); };
        }
예제 #22
0
        private void ExecuteSave(object param)
        {
            try
            {
                if (editCourse != null)
                {
                    editCourse.Name             = Name;
                    editCourse.StudyProgramId   = StudyProgramId;
                    editCourse.StudyProgramName = view.cbxStudyPrograms.Text;
                    editCourse.ProfessorId      = ProfessorId;
                    editCourse.ProfessorName    = view.cbxProfessors.Text;
                    editCourse.Assistant        = Assistant;
                    editCourse.ETCS             = ETCS;

                    ServiceDataProvider.EditCourse(editCourse);
                    eventAggregator.GetEvent <CourseEvent>().Publish(editCourse);
                }
                else
                {
                    Course newCourse = new Course()
                    {
                        Name           = Name,
                        StudyProgramId = StudyProgramId,
                        ProfessorId    = ProfessorId,
                        Assistant      = Assistant,
                        ETCS           = ETCS
                    };

                    ServiceDataProvider.AddCourse(newCourse);
                }
            }
            catch (Exception e)
            {
                e.Message.ToString();
            }
            finally
            {
                view.Close();
            }
        }
예제 #23
0
        private void ExecuteSave(object param)
        {
            try
            {
                if (editSP != null)
                {
                    editSP.Name               = Name;
                    editSP.DepartmentId       = DepartmentId;
                    editSP.SelffinancedPlaces = SelffinancedPlaces;
                    editSP.BudgetPlaces       = BudgetPlaces;
                    editSP.Tuition            = Tuition;

                    ServiceDataProvider.EditStudyProgram(editSP);
                    eventArgs.GetEvent <StudyProgramEvent>().Publish(editSP);
                }
                else
                {
                    StudyProgram newStudyProgram = new StudyProgram()
                    {
                        Name               = Name,
                        DepartmentId       = DepartmentId,
                        SelffinancedPlaces = SelffinancedPlaces,
                        BudgetPlaces       = BudgetPlaces,
                        Tuition            = Tuition
                    };

                    ServiceDataProvider.AddStudyProgram(newStudyProgram);
                }
            }
            catch (Exception e)
            {
                e.Message.ToString();
            }
            finally
            {
                view.Close();
            }
        }
예제 #24
0
        private void ExecuteSave(object param)
        {
            try
            {
                if (editDepartment != null)
                {
                    editDepartment.DepartmentHead = DepartmentHead;
                    editDepartment.FoundationYear = FoundationYear;
                    editDepartment.Name           = Name;
                    editDepartment.Website        = Website;

                    ServiceDataProvider.EditDepartment(editDepartment);
                    eventAggregator.GetEvent <DepartmentEvent>().Publish(editDepartment);
                }
                else
                {
                    Department newDepartment = new Department()
                    {
                        Name           = Name,
                        FoundationYear = FoundationYear,
                        DepartmentHead = DepartmentHead,
                        Website        = website
                    };

                    ServiceDataProvider.AddDepartment(newDepartment);
                }
            }
            catch (Exception e)
            {
                e.Message.ToString();
            }
            finally
            {
                view.Close();
            }
        }
예제 #25
0
 public ProfessorViewModel()
 {
     Professors = new ObservableCollection <Professor>(ServiceDataProvider.GetAllProfessors());
     ServiceDataProvider.AddProfessorNotification += ServiceDataProvider_AddProfessorNotification;
 }
예제 #26
0
 public DepartmentViewModel()
 {
     Departments = new ObservableCollection <Department>(ServiceDataProvider.GetAllDepartments());
     ServiceDataProvider.AddDepartmentNotification += ServiceDataProvider_AddDepartmentNotification;
 }
예제 #27
0
 public ExamPeriodViewModel()
 {
     ExamPeriods = new ObservableCollection <ExamPeriod>(ServiceDataProvider.GetAllExamPeriods());
     ServiceDataProvider.AddExamPeriodNotification += ServiceDataProvider_AddExamPeriodNotification;
 }
예제 #28
0
 private async Task LoadCountries()
 {
     // download the list
     Countries = await ServiceDataProvider.GetCountriesList();
 }
예제 #29
0
        private void CbxDepartments_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
        {
            var selectedDepartmentId = DepartmentId;

            ObservableCollection <StudyProgram> SP = new ObservableCollection <StudyProgram>(ServiceDataProvider.GetAllSPForDepartmentId(selectedDepartmentId));

            if (SP.Count == 0)
            {
                e.Handled = true;
            }
            view.cbxStudyPrograms.ItemsSource = SP;
        }