예제 #1
0
        private void AddStudToLab(student s, lab l)
        {
            // add stud to new lab
            context.AddStudToLab(s, l);

            // add present for each labdate for student
            context.GetLabdatesOfLab(l.labID)
            .ForEach(lD => {
                dataAccess.PresentContext.AddOne(
                    new present {
                    labdate_labdateID = lD.labdateID,
                    note = "",
                    student_studentID = s.studentID,
                    wasPresent        = 0
                });
            });

            // add TaskDone for each Task for student
            context.GetTasksOfLab(l.labID)
            .ForEach(t => {
                dataAccess.TaskDoneContext.AddOne(
                    new taskdone {
                    isDone            = 0,
                    student_studentID = s.studentID,
                    task_taskID       = t.taskID
                });
            });
        }
예제 #2
0
        public Lab ConvertLab(lab l)
        {
            Lab labor = new Lab {
                LabID           = l.labID,
                LabNumber       = l.labNumber,
                Course_courseID = l.course_courseID,
                Course          = new Course(),
                Labdates        = new List <Labdate>(),
                Tasks           = new List <Tasks>(),
                Students        = new List <Student>(),

                //new Property for UI
                LabDateCount = Context.GetLabdatesOfLab(l.labID).Count,
                StudentCount = Context.GetStudentsOfLab(l.labID).Count
            };

            return(labor);
        }
예제 #3
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();
        }