Esempio n. 1
0
        private bool CanStudentGetHelpDegreeForSecoundYear(Students student, Years year)
        {
            var faildSubject = student.StudentSubjectWithoutDuplicate.Where(c => !c.IsSuccess()).ToList();

            if (faildSubject.Any(c => !c.IsNominate()))
            {
                return(false);
            }

            year.GetSubjectCountAndHelpDegreeCount(student, out int helpDgree, out int subjectCount);
            if (faildSubject.Count() > subjectCount)
            {
                return(false);
            }

            foreach (var item in faildSubject)
            {
                helpDgree -= (int)Math.Ceiling(item.SucessMark - item.OrignalTotal);
                if (helpDgree < 0)
                {
                    return(false);
                }
            }
            return(true);
        }
Esempio n. 2
0
        private bool CanStudentGetHelpDegreeForFirstYear(Students student, Years year)
        {
            #region ناجح
            //ناجح نظامي
            var sucessCount = student.StudentSubjectWithoutDuplicate.Where(c => c.IsSuccess()).Count();
            if (sucessCount >= BusinessLogicHelper.SucessCount)
            {
                return(false);
            }
            //نجاح إداري
            var numberOfSubjectOfAdministrativeLift = year.YearSystemNavigation.SettingYearSystem.Where(c => c.SettingId == (int)SettingEnum.NumberOfSubjectOfAdministrativeLift).First().Count;
            if (numberOfSubjectOfAdministrativeLift != BusinessLogicHelper.NumberOfSubjectOfAdministrativeLiftIfNotExist && sucessCount >= numberOfSubjectOfAdministrativeLift)
            {
                return(false);
            }
            #endregion

            var faildSubject = student.StudentSubjectWithoutDuplicate.Where(c => c.IsNominate() && !c.IsSuccess()).ToList();
            faildSubject.Sort((s1, s2) => s2.OrignalTotal.CompareTo(s1.OrignalTotal));

            var stillToSuccess = BusinessLogicHelper.SucessCount - sucessCount;
            if (numberOfSubjectOfAdministrativeLift != BusinessLogicHelper.NumberOfSubjectOfAdministrativeLiftIfNotExist)
            {
                stillToSuccess = numberOfSubjectOfAdministrativeLift - sucessCount;
            }
            year.GetSubjectCountAndHelpDegreeCount(student, out int helpDgree, out int helpDegreeSubjectCount);
            decimal totalHelpDegree = helpDgree;


            int oldGivenHelpDgree            = TotlaHelpDgree(student);
            int oldCountSubjectHaveHelpDgree = SumOfSubjectThatHaveHelpDgree(student);


            if (oldCountSubjectHaveHelpDgree != 0)
            {
                if (oldCountSubjectHaveHelpDgree != stillToSuccess || oldGivenHelpDgree > totalHelpDegree)
                {
                    student.StudentSubject.ToList().ForEach(c =>
                    {
                        c.HelpDegree = false;
                        _abstractUnitOfWork.Repository <StudentSubject>().Update(c, SentencesHelper.System);
                    });
                }
                else
                {
                    return(false);
                }
            }
            //إذا عدد المواد يلي بقيانلو لينجح بيقبلو يتقسمو على عدد المواد
            if (stillToSuccess <= helpDegreeSubjectCount)
            {
                foreach (var item in faildSubject)
                {
                    if (helpDegreeSubjectCount == 0 || totalHelpDegree == 0 || stillToSuccess == 0)
                    {
                        break;
                    }
                    var helpDegreeForSubject = item.SucessMark - item.OrignalTotal;
                    if (helpDegreeForSubject > totalHelpDegree)
                    {
                        break;
                    }
                    totalHelpDegree -= helpDegreeForSubject;
                    helpDegreeSubjectCount--;
                    stillToSuccess--;
                }
                if (stillToSuccess == 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }