示例#1
0
        public Labdate ConvertLabdate(labdate l)
        {
            Labdate labdate = new Labdate {
                LabdateID = l.labdateID,
                Date      = l.date,
                Lab_labID = l.lab_labID,
                Lab       = new Lab(),
                Presents  = new List <Present>()
            };

            return(labdate);
        }
示例#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();
        }