示例#1
0
        // Initializes a new instance of the Studentviewmodel class.
        public StudentViewModel(IStudentDB studentDB, IPraktikaDB praktikaDB, IFirmenDB firmenDB, IDozentDB dozentDB, IDialogService dialogservice)
        {
            try
            {
                _studentDB     = studentDB;
                _praktikaDB    = praktikaDB;
                _firmenDB      = firmenDB;
                _dozentDB      = dozentDB;
                _dialogservice = dialogservice;

                //Student Commands
                RefreshCommand       = new RelayCommand(RefreshExecute);
                NewStudentCommand    = new RelayCommand(NewStudentExecute);
                SaveStudentCommand   = new RelayCommand(SaveStudentExecute, CanSaveStudent);
                CancelStudentCommand = new RelayCommand(CancelStudentExecute);
                DeleteStudentCommand = new RelayCommand(DeleteStudentExecute, CanDeleteStudent);
                PrintReportCommand   = new RelayCommand(PrintReportExecute, CanPrintReportExecute);

                //Praktika Commands
                NewPraktikaCommand    = new RelayCommand(NewPraktikaExecute, CanNewPraktikaExecute);
                NextCommand           = new RelayCommand(NextExecute, CanNextExecute);
                PreviousCommand       = new RelayCommand(PreviousExecute, CanPreviousExecute);
                SavePraktikaCommand   = new RelayCommand(SavePraktikaExecute);
                CancelPraktikaCommand = new RelayCommand(CancelPraktikaExecute);

                StudentList = new ObservableCollection <Student>();
                StudentList = _studentDB.GetAllStudents();

                FirmaList = new ObservableCollection <Firmen>();
                FirmaList = _firmenDB.GetAllFirmen();

                DozentList = new ObservableCollection <Dozent>();
                DozentList = _dozentDB.GetAllDozents();


                SelectedStudent = StudentList[0];

                TempSelectedStudent.IsOkChanged += OnTempSelectedStudentPropertyChanged;

                StudiengangItems = new ObservableCollection <string>
                {
                    "BA BWL Präsenz",
                    "BA W-Informatik Präsenz",
                    "BA BWL online",
                    "BA BWL TZ online",
                    "BA W-Informatik online",
                    "MA BWL non-konsekutiv"
                };
            }
            catch (Exception e)
            {
                throw e;
            }
        }
示例#2
0
        private void RefreshExecute()
        {
            _studentDB.RefreshDBContext(); //Refresh DBContext
            _firmenDB.RefreshDBContext();
            _dozentDB.RefreshDBContext();

            StudentList = _studentDB.GetAllStudents(); //Get all students into StudentList
            FirmaList   = _firmenDB.GetAllFirmen();    //Get all Firmen into FirmaList
            DozentList  = _dozentDB.GetAllDozents();   //Get all DozentNames into DozentList

            if (StudentList.Contains(SelectedStudent))
            {
                SelectedStudent = _studentDB.RefreshEntity(SelectedStudent); //Refresh the currently selected student
            }
            //If currently selected Student had already been deleted in database by another user, then set to the first item in list
            else
            {
                MessageBox.Show("Die ausgewählten Daten sind nicht mehr in der Datenbank verfügbar.", "Information", MessageBoxButton.OK, MessageBoxImage.Information);
                SelectedStudent = StudentList[0];
            }
        }