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; }
public StudyProgramViewModel(IEventAggregator eventArggr) { this.eventArggr = eventArggr; StudyPrograms = new ObservableCollection <StudyProgram>(ServiceDataProvider.GetAllStudyPrograms()); ServiceDataProvider.AddStudyProgramNotification += ServiceDataProvider_AddStudyProgramNotification; SubscribeToParentTableNameChange(eventArggr); }
public CourseViewModel(IEventAggregator eventAggregator) { this.eventAggregator = eventAggregator; Courses = new ObservableCollection <Course>(ServiceDataProvider.GetAllCourses()); ServiceDataProvider.AddCourseNotification += ServiceDataProvider_AddCourseNotification; SubscribeToParentTableNameChange(eventAggregator); }
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)); }
private void ExecuteRemove(object p) { if (p != null && p is Course) { var course = p as Course; ServiceDataProvider.DeleteCourse(course.CourseId); Courses.Remove(course); } }
private void ExecuteRemove(object p) { if (p != null && p is Exam) { var exam = p as Exam; ServiceDataProvider.DeleteExam(exam.ExamId); Exams.Remove(exam); } }
private void ExecuteRemove(object p) { if (p != null && p is Student) { var student = p as Student; ServiceDataProvider.DeleteStudent(student.StudentId); Students.Remove(student); } }
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(); } }
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)); } }
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(); } }
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(); } }
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; } }
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)); } } }
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)); } } }
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)); } } }
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(); } }
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)); } } }
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]; } }
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; } }
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()); }
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(); }; }
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(); } }
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(); } }
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(); } }
public ProfessorViewModel() { Professors = new ObservableCollection <Professor>(ServiceDataProvider.GetAllProfessors()); ServiceDataProvider.AddProfessorNotification += ServiceDataProvider_AddProfessorNotification; }
public DepartmentViewModel() { Departments = new ObservableCollection <Department>(ServiceDataProvider.GetAllDepartments()); ServiceDataProvider.AddDepartmentNotification += ServiceDataProvider_AddDepartmentNotification; }
public ExamPeriodViewModel() { ExamPeriods = new ObservableCollection <ExamPeriod>(ServiceDataProvider.GetAllExamPeriods()); ServiceDataProvider.AddExamPeriodNotification += ServiceDataProvider_AddExamPeriodNotification; }
private async Task LoadCountries() { // download the list Countries = await ServiceDataProvider.GetCountriesList(); }
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; }