예제 #1
0
        private void DeleteCourseProc()
        {
            if (MessageBox.Show("Are you sure?", "", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
            {
                //remove course
                //remove session
                //remove candidatesession
                //remove sessionlocation
                //remove qualificationsdevelopedbycourse
                //remove prerequisitesforcourse
                foreach (var v in CandidateSessionService.GetAll().Where(d => d.Session.CourseId == Course.Id))
                {
                    CandidateSessionService.Remove(v.CandidateId, v.SessionId);
                }

                foreach (var v in SessionService.GetAllSessions().Where(d => d.CourseId == Course.Id))
                {
                    SessionService.RemoveSession(v);
                }

                foreach (var v in SessionLocationService.GetAll().Where(d => d.Session.CourseId == Course.Id))
                {
                    SessionLocationService.Remove(v.SessionId, v.LocationId);
                }

                foreach (var v in SessionLocationService.GetAll().Where(d => d.Session.CourseId == Course.Id))
                {
                    SessionLocationService.Remove(v.SessionId, v.LocationId);
                }

                foreach (var v in QualificationDevelopedByCourseService.GetAll().Where(d => d.CourseId == Course.Id))
                {
                    QualificationDevelopedByCourseService.Remove(Course.Id, v.QualificationId);
                }

                foreach (var v in PrerequisitesForCourseService.GetAll().Where(d => d.CourseId == Course.Id))
                {
                    PrerequisitesForCourseService.Remove(Course.Id, v.QualificationId);
                }
                CourseService.RemoveCourse(Course);

                BackProc();
            }
        }
예제 #2
0
        private void LoadContents(LoadSessionAttendanceViewMessage loadSessionAttendanceViewMessage)
        {
            var candidateSessions =
                CandidateSessionService.GetAll().Where(d => d.SessionId == SelectedSession.Id).ToList();

            CandidateWithCheckBoxDtos.Clear();
            foreach (var v in CandidateService.GetAllCandidatesAndMapToCandidateWithCheckBoxDTO())
            {
                CandidateWithCheckBoxDtos.Add(v);
            }

            foreach (var v in CandidateWithCheckBoxDtos)
            {
                if (candidateSessions.Any(d => d.CandidateId == v.Candidate.Id))
                {
                    v.IsSelected = true;
                }
            }
        }
예제 #3
0
        private void ConfirmAttendanceProc()
        {
            if (MessageBox.Show("Are you sure?", "", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
            {
                if (CandidateWithCheckBoxDtos.Count(d => d.IsSelected) > SelectedSession.Location.Capacity)
                {
                    MessageBox.Show("Too many attendees");
                    return;
                }
                foreach (var v in CandidateWithCheckBoxDtos)
                {
                    if (v.IsSelected)
                    {
                        var candidateQualifications = CandidateQualificationService.GetAll()
                                                      .Where(d => d.CandidateId == v.Candidate.Id);
                        var coursePrerequisites = PrerequisitesForCourseService.GetAll()
                                                  .Where(d => d.CourseId == SelectedSession.Course.Id);
                        if (CandidateIsNotQualified(v.Candidate, candidateQualifications, coursePrerequisites))
                        {
                            MessageBox.Show($"{v.Candidate.FullName} is not qualified for this course");
                            return;
                        }
                        CandidateSessionService.Add(new Candidate_Session()
                        {
                            Candidate = v.Candidate,
                            Session   = SelectedSession
                        });
                    }
                    else
                    {
                        CandidateSessionService.Remove(v.Candidate.Id, SelectedSession.Id);
                    }
                }

                var candidateSessions = CandidateSessionService.GetAll().Where(d => d.SessionId == SelectedSession.Id);
                SelectedSession = SessionService.UpdateSessionNumberOfAttendees(SelectedSession, candidateSessions.Count());
            }
            BackProc();
        }