Beispiel #1
0
        public void ProcessStudentState(Students student, bool testHelpDegree = true)
        {
            Years year = _abstractUnitOfWork.Repository <Years>().GetIQueryable(c => c.Id == student.CurrentYearId)
                         .Include(c => c.YearSystemNavigation)
                         .ThenInclude(c => c.SettingYearSystem)
                         .Include(c => c.ExamSemester)
                         .First();

            if (student.CurrentStudyYearId == (int)StudyYearEnum.SecoundYear)
            {
                var nonNominateSubject = student.StudentSubjectWithoutDuplicate.Where(c => !c.IsNominate()).ToList();
                if (year.ExamSystemNavigation.GraduateStudentsSemester > 0 && nonNominateSubject.Count > 0)
                {
                    var theredSemesterId = year.GetSemeserIdByNumber(3);
                    student.StudentSubject.Where(c => c.ExamSemesterId == theredSemesterId).ToList().ForEach(subject =>
                    {
                        _abstractUnitOfWork.Remove(subject, SentencesHelper.System + "test");
                        student.StudentSubject.Remove(subject);
                        _abstractUnitOfWork.Commit();
                    });
                }
            }
            if (student.StudentSubject.Any(c => c.PracticalDegree == null || c.TheoreticlaDegree == null))
            {
                var nullAbleSubject = student.StudentSubject.Where(c => c.PracticalDegree == null || c.TheoreticlaDegree == null).ToList();
                student.Lastregistration.FinalStateId = null;
                student.Lastregistration.SystemNote   = String.Empty;
                _abstractUnitOfWork.Update(student.Lastregistration, SentencesHelper.System);
                return;
            }
            var sucessCount = student.StudentSubjectWithoutDuplicate.Where(c => c.IsSuccess()).Count();
            var successWithHelpDegreeCount = student.StudentSubjectWithoutDuplicate.Where(c => c.HelpDegree == true).ToList();


            if (student.CurrentStudyYearId == (int)StudyYearEnum.FirstYear)
            {
                var studentState = StudentStateForFirstYear(student, out string Note);
                if (studentState != StudentStateEnum.unknown)
                {
                    student.Lastregistration.FinalStateId = (int)studentState;
                    student.Lastregistration.SystemNote   = Note;
                    student.StudentSubject.Where(c => c.HelpDegree == true).ToList().ForEach(c => c.HelpDegree = false);
                }
                else
                {
                    if (testHelpDegree && this.CanStudentGetHelpDegree(student, year))
                    {
                        student.StudentSubject.Where(c => c.HelpDegree == true).ToList().ForEach(c => c.HelpDegree = false);
                        student.Lastregistration.FinalStateId = (int)StudentStateEnum.unknown;
                        student.Lastregistration.SystemNote   = SentencesHelper.CanPutHelpDgree;
                    }
                    else if (!student.CurrentStudentSubject.Where(c => c.HelpDegree == true).Any())
                    {
                        if (student.CurrentStudentStatusId == (int)StudentStateEnum.newStudent)
                        {
                            student.Lastregistration.FinalStateId = (int)StudentStateEnum.unSuccessful;
                            student.Lastregistration.SystemNote   = string.Empty;
                        }
                        else if (student.CurrentStudentStatusId == (int)StudentStateEnum.unSuccessful || student.CurrentStudentStatusId == (int)StudentStateEnum.Decree)
                        {
                            student.Lastregistration.FinalStateId = (int)StudentStateEnum.Drained;
                            student.Lastregistration.SystemNote   = string.Empty;
                        }
                    }
                    else
                    {
                        //added while i'm sleping
                        student.CurrentStudentSubject.Where(c => c.HelpDegree == true).ToList()
                        .ForEach(c =>
                        {
                            c.HelpDegree = false;
                            _abstractUnitOfWork.Update(c, SentencesHelper.System);
                        });
                        if (testHelpDegree && this.CanStudentGetHelpDegree(student, year))
                        {
                            student.Lastregistration.FinalStateId = (int)StudentStateEnum.unknown;
                            student.Lastregistration.SystemNote   = SentencesHelper.CanPutHelpDgree;
                        }
                        else
                        {
                            if (student.CurrentStudentStatusId == (int)StudentStateEnum.newStudent)
                            {
                                student.Lastregistration.FinalStateId = (int)StudentStateEnum.unSuccessful;
                                student.Lastregistration.SystemNote   = string.Empty;
                            }
                            else if (student.CurrentStudentStatusId == (int)StudentStateEnum.unSuccessful || student.CurrentStudentStatusId == (int)StudentStateEnum.Decree)
                            {
                                student.Lastregistration.FinalStateId = (int)StudentStateEnum.Drained;
                                student.Lastregistration.SystemNote   = string.Empty;
                            }
                        }
                    }
                }
                ////added while i'm sleping
                //_abstractUnitOfWork.Update(student.Lastregistration, SentencesHelper.System);
            }
            //for secound year
            else
            {
                var faildStatue = student.CurrentStudentStatusId == (int)StudentStateEnum.successful || student.CurrentStudentStatusId == (int)StudentStateEnum.transported ? StudentStateEnum.unSuccessful : StudentStateEnum.Drained;
                if (student.StudentSubjectWithoutDuplicate.Any(c => !c.IsNominate()))
                {
                    student.Lastregistration.FinalStateId = (int)faildStatue;
                }
                else if (student.StudentSubjectWithoutDuplicate.All(c => c.IsSuccess() | c.IsSucessWihtHelpDegree()))
                {
                    student.Lastregistration.FinalStateId = (int)StudentStateEnum.Graduated;
                }
                else
                {
                    if (testHelpDegree && CanStudentGetHelpDegree(student, year))
                    {
                        student.Lastregistration.FinalStateId = (int)StudentStateEnum.unknown;
                        student.Lastregistration.SystemNote   = SentencesHelper.CanPutHelpDgree;
                    }
                    //testing for grudate semester
                    else
                    {
                        var numberofSubjectForGraduateStudentSemester = year.NumberofSubjectForGraduateStudentSemester();
                        // if theres an thered semester for graduate student
                        if (numberofSubjectForGraduateStudentSemester > 0)
                        {
                            var semesterId = year.GetSemeserIdByNumber(3);


                            var faildSubject            = student.StudentSubjectWithoutDuplicate.Where(c => !c.IsSuccess()).ToList();
                            var subjectInGruateSemester = student.StudentSubjectWithoutDuplicate.Where(c => c.ExamSemesterId == semesterId).ToList();
                            if (!faildSubject.Except(subjectInGruateSemester).Any())
                            {
                                student.Lastregistration.FinalStateId = (int)faildStatue;
                                return;
                            }
                            var union = faildSubject.Union(subjectInGruateSemester).ToList();
                            if (numberofSubjectForGraduateStudentSemester >= union.Count() && faildSubject.All(c => c.IsNominate()))
                            {
                                faildSubject.ForEach(element =>
                                {
                                    StudentSubject studentSubject = new StudentSubject()
                                    {
                                        SubjectId       = element.SubjectId,
                                        Ssn             = element.Ssn,
                                        PracticalDegree = element.PracticalDegree,
                                        ExamSemesterId  = semesterId
                                    };
                                    _abstractUnitOfWork.Add(studentSubject, SentencesHelper.System);
                                });
                                //student.Lastregistration.FinalStateId = (int)StudentStateEnum.unknown;
                                student.Lastregistration.SystemNote = SentencesHelper.canApplyForGraduateSemester;
                            }
                            else
                            {
                                subjectInGruateSemester.ForEach(s =>
                                {
                                    _abstractUnitOfWork.Remove(s, SentencesHelper.System);
                                });

                                student.Lastregistration.FinalStateId = (int)faildStatue;
                            }
                        }
                        else
                        {
                            student.Lastregistration.FinalStateId = (int)faildStatue;
                        }
                    }
                }
            }
            _abstractUnitOfWork.Update(student.Lastregistration, SentencesHelper.System);
        }