示例#1
0
        public void FillLists()
        {
            ExistingLabNumbers = new ObservableCollection <int>();
            context.GetLabsOfCourse(CourseID).ForEach(l => {
                ExistingLabNumbers.Add(l.labNumber);
            });

            NotUsedLabNumbers = new ObservableCollection <int>();
            for (var i = 1; i <= 20; i++)
            {
                NotUsedLabNumbers.Add(i);
            }

            ExistingLabNumbers.ToList().ForEach(labNr => {
                if (NotUsedLabNumbers.Contains(labNr))
                {
                    NotUsedLabNumbers.Remove(labNr);
                }
            });

            Weekdays = new ObservableCollection <string> {
                "Montag",
                "Dienstag",
                "Mittwoch",
                "Donnerstag",
                "Freitag"
            };

            // Fill Task Numbers
            TaskNumbers = new ObservableCollection <int>();
            for (int i = 0; i < 15; i++)
            {
                TaskNumbers.Add(i);
            }

            // Fill Days
            Days = new ObservableCollection <int>();
            for (int i = 1; i < 32; i++)
            {
                Days.Add(i);
            }

            // Fill Months
            Months = new ObservableCollection <string> {
                "Januar",
                "Februar",
                "März",
                "April",
                "Mai",
                "Juni",
                "Juli",
                "August",
                "September",
                "Oktober",
                "November",
                "Dezember"
            };

            // Fill Years
            Years = new ObservableCollection <int> {
                2020,
                2021,
                2022,
                2023
            };

            // Fill Hours
            Hours = new ObservableCollection <int>();
            for (int i = 8; i < 23; i++)
            {
                Hours.Add(i);
            }

            // Fill Minutes
            Minutes = new ObservableCollection <string> {
                "00",
                "15",
                "30",
                "45"
            };

            // Fill Salutations
            Salutations = new ObservableCollection <string> {
                "Herr",
                "Frau"
            };

            // Fill StudyCourses
            StudyCourses = new ObservableCollection <string> {
                "AI",
                "MI"
            };
        }
示例#2
0
        public LabDetailViewModel(int labID)
        {
            #region initialize private properties
            exporter   = new LabExporter();
            dataAccess = new DataAccess();
            context    = dataAccess.Context;
            #endregion

            #region setProperties
            #region Set Lab Properties
            LabID = labID;

            var lab = dataAccess.GetLabById(labID);

            LabNumber = "Labornummer: " + lab.LabNumber;

            List <Labdate> labDates = new List <Labdate>();
            context.GetLabdatesOfLab(lab.LabID)
            .ForEach(l => labDates.Add(dataAccess.ConvertLabdate(l)));

            if (labDates.Count > 0)
            {
                Labdate labDate = labDates.First();
                LabWeekday = (labDate.Date.DayOfWeek).ToString();
                LabHour    = labDate.Date.Hour;
                LabMinute  = (labDate.Date.Minute);
                var minute = (LabMinute.ToString().Equals("0")) ? "00" : LabMinute.ToString();
                LabTime = $"{labDate.Date.DayOfWeek}, {labDate.Date.Hour}:{minute} Uhr";
            }
            else
            {
                LabTime = "Es gibt keine Termine";
            }

            LabDateCount = labDates.Count;
            #endregion

            #region Course Info
            CourseID = context.GetCourseOfLab(lab.LabID).courseID;
            Lecture  = dataAccess.Context.GetCourseOfLab(lab.LabID).name;
            #endregion

            #region Transfer Student Popup
            ExistingLabNumbers = new ObservableCollection <int>();
            context.GetLabsOfCourse(CourseID).ForEach(l => {
                ExistingLabNumbers.Add(l.labNumber);
            });
            #endregion
            #endregion

            FillAll();

            FillLists();

            #region createCommands
            #region Student
            AddStudentCommand              = new RelayCommand(AddStudent);
            PrintStudentInfoCommand        = new RelayCommandParameterized((parameter) => PrintStudentInfo());
            AddStudentToLabCommand         = new RelayCommand(AddStudentToLab);
            TransferStudentCommand         = new RelayCommand(TransferStudent);
            CloseStudentPopupCommand       = new RelayCommand(CloseStudentPopup);
            CloseEditStudentPopupCommand   = new RelayCommand(CloseEditStudentPopup);
            UpdateStudentCommand           = new RelayCommandParameterized((parameter) => UpdateStudent(parameter));
            EditStudentCommand             = new RelayCommandParameterized((parameter) => UpdateStudentPopUp(parameter));
            DeleteStudentCommand           = new RelayCommandParameterized((parameter) => DeleteStudent(parameter));
            DeleteStudentPopupCommand      = new RelayCommandParameterized((parameter) => DeleteStudentPopup(parameter));
            CloseDeleteStudentPopupCommand = new RelayCommand(CloseDeleteStudentPopup);
            #endregion

            #region Attendance
            PrintAttendanceCommand   = new RelayCommandParameterized((parameter) => PrintAttendance());
            ClickedAttendanceCommand = new RelayCommandParameterized((parameter) => ClickedAttendance(parameter));
            #endregion

            #region Task
            ClickedTaskCommand = new RelayCommandParameterized((parameter) => ClickedTask(parameter));
            #endregion

            #region Lab
            EditLabCommand       = new RelayCommand(OpenLabPopup);
            UpdateLabCommand     = new RelayCommand(UpdateLabDetails);
            CloseLabPopupCommand = new RelayCommand(CloseLabPopup);
            #endregion

            #region Course
            GoToCourseDetailCommand = new RelayCommand(GoBack);
            #endregion

            #region Note
            EditNoteCommand       = new RelayCommandParameterized((parameter) => OpenEditNotePopup(parameter));
            UpdateNoteCommand     = new RelayCommand(UpdateNote);
            CloseNotePopupCommand = new RelayCommand(CloseNotePopup);
            #endregion

            #region PDF
            PrintTasksCommand       = new RelayCommandParameterized((parameter) => PrintTasks());
            ClosePdfFeedbackCommand = new RelayCommand(ClosePdfPopup);
            #endregion

            #region InputFeedback
            CloseInputFeedbackCommand = new RelayCommand(InputFeedbackPopup);
            #endregion
            #endregion

            RefreshCourseDetailView();
        }