public ActionResult DeleteCollegeRate(string code, string collegeId, string termId)
        {
            var professorCode = Convert.ToInt32(code);
            var tid           = Convert.ToInt32(termId);
            var term          = _termService.Get(g => g.Id == tid);
            var professor     = _professorService.Get(g => g.ProfessorCode == professorCode && g.Term.Id == tid);

            professor.ProfessorAccessStatus = null;
            _professorService.Update(professor);
            var scores = _professorScoreService.GetMany(g =>
                                                        g.Professor.ProfessorCode == professorCode &&
                                                        g.Term.Id == term.Id && g.Score.Indicator.CountOfType == "p" + (int)IndicatorProfessorName.وضعیت_دسترسی_به_استاد_و_تعامل_با_دانشکده).ToList();

            if (scores != null && scores.Count() > 0)
            {
                foreach (var score in scores)
                {
                    if (score.EducationalGroup.College.Id == Convert.ToInt32(collegeId))
                    {
                        _professorScoreService.Delete(score);
                    }
                }
            }
            return(null);
        }
Esempio n. 2
0
        public void SetUniversityLevel(string id, string scoreId)
        {
            var indicator    = _indicatorService.Get(g => g.CountOfType == "p" + (int)IndicatorProfessorName.رتبه_دانشگاه_محل_تحصیل);
            var scores       = indicator.Scores.ToList();
            var universityId = Convert.ToInt32(id);
            var university   = _mappingService.Get(g => g.TypeId == universityId && g.MappingType.Id == 4);
            var uniLevel     = _universityLevelMappingService.Get(g => g.UniversityId == universityId);
            var _scoreId     = Convert.ToInt32(scoreId);
            var score        = scores.FirstOrDefault(w => w.Id == _scoreId);

            if (uniLevel == null && score != null)
            {
                _universityLevelMappingService.Add(new UniversityLevelMapping
                {
                    CreationDate     = DateTime.Now,
                    LastModifiedDate = DateTime.Now,
                    IsActive         = true,
                    Score            = new Model.Models.Score
                    {
                        Id = score.Id,
                    },
                    UniversityId   = universityId,
                    UniversityName = university.TypeName
                });
            }
            else if (uniLevel != null && score == null)
            {
                _universityLevelMappingService.Delete(uniLevel);
            }
            else
            {
                uniLevel.Score = new Model.Models.Score
                {
                    Id = score.Id,
                };
                _universityLevelMappingService.Update(uniLevel);
            }

            //-- Set Professor Scores Begin
            var currentTerm = _termService.Get(g => g.IsCurrentTerm);
            var professors  = _professorService.GetMany(g => g.UniversityStudyPlace != null && g.UniversityStudyPlace != 0 && g.UniversityStudyPlace == universityId &&
                                                        g.Term.Id == currentTerm.Id && g.IsActive == true).ToList();

            foreach (var professor in professors)
            {
                var professorScores          = _professorScoreService.GetMany(g => g.Professor.Id == professor.Id && g.Term.Id == currentTerm.Id).ToList();
                var professorScoresIndicator = professorScores.Where(w => scores.Select(s => s.Id).Contains(w.Score.Id));
                //var professorScore = _professorScoreService.GetMany(g => scores.Select(s => s.Id).Contains(g.Score.Id) && g.Professor.Id == professor.Id).ToList();
                if (professorScoresIndicator.Count() > 0)
                {
                    foreach (var ps in professorScoresIndicator)
                    {
                        ps.Score.Id = score.Id;
                        _professorScoreService.Update(ps);
                    }
                }
                else
                {
                    foreach (var group in _educationalClassService.GetMany(g => g.Professor.Id == professor.Id).Select(s => s.EducationalGroup))
                    {
                        _professorScoreService.Add(new ProfessorScore
                        {
                            EducationalGroup = group,
                            Professor        = professor,
                            Score            = score,
                            Term             = currentTerm,
                            CurrentScore     = Convert.ToInt32(score.Point * indicator.Ratio.Point)
                        });
                    }
                }
            }
            //-- Set Professor Scores End
        }
Esempio n. 3
0
        public void UpdateClassSessions(int classCode, int onlineHeld, int presentHeld, int other, string termId = null, bool manualUpdate = false)
        {
            Term currentTerm = null;

            if (string.IsNullOrEmpty(termId))
            {
                currentTerm = GetCurrentTerm();
            }
            else
            {
                var tid = Convert.ToInt32(termId);
                currentTerm = _termService.Get(g => g.Id == tid);
            }
            var obj = _educationalClassService.Get(g => g.CodeClass == classCode && g.Term.Id == currentTerm.Id);

            if ((manualUpdate && onlineHeld >= 0) || (!manualUpdate && onlineHeld > 0))
            {
                obj.OnlineHeldingCount = onlineHeld;
            }
            if ((manualUpdate && presentHeld >= 0) || (!manualUpdate && presentHeld > 0))
            {
                obj.PersentHeldingCount = presentHeld;
            }
            if ((manualUpdate && other >= 0) || (!manualUpdate && other > 0))
            {
                obj.OthersHeldingCount = other;
            }
            _educationalClassService.Update(obj);


            //var classes = _educationalClassService.GetMany(g => g.Professor.Id == obj.Professor.Id && g.Term.Id == currentTerm.Id && g.EducationalGroup.Id == obj.EducationalGroup.Id);
            //obj.Professor.OnlineSession = classes.Sum(s => s.OnlineHeldingCount);
            //obj.Professor.InPersonSession = classes.Sum(s => s.PersentHeldingCount);
            //obj.Professor.OthersSession = classes.Sum(s => s.OthersHeldingCount);
            //_professorService.Update(obj.Professor);

            var indicatorCountOfTypet = "p" + (int)IndicatorProfessorName.تعداد_جلسات_برگزار_شده_کلاس;
            var profAllScores         = _professorScoreService.GetMany(g =>
                                                                       g.Professor.Id == obj.Professor.Id &&
                                                                       g.Term.Id == currentTerm.Id &&
                                                                       g.Score.Indicator.CountOfType == indicatorCountOfTypet);

            Model.Models.ProfessorScore profScore = new Model.Models.ProfessorScore();
            if (profAllScores.Count() > 0)
            {
                profScore = profAllScores.Where(w => w.EducationalGroup.Id == obj.EducationalGroup.Id).FirstOrDefault();
            }

            //var totalCount = (obj.Professor.OnlineSession + obj.Professor.InPersonSession + obj.Professor.OthersSession) / classes.Count();
            //var score = _scoreService.Get(g => g.MinValue <= totalCount && g.MaxValue >= totalCount && g.Indicator.CountOfType == indicatorCountOfTypet);


            var listOfCountClass = new List <decimal>();


            var listOfClass = _educationalClassService.GetMany(x => x.Professor.Id == obj.Professor.Id &&
                                                               x.EducationalGroup.Id == obj.EducationalGroup.Id &&
                                                               x.Term.Id == currentTerm.Id &&
                                                               x.IsActive == true).ToList();

            var indicator7 = _indicatorService
                             .Get(y => y.CountOfType == ("p" + (int)IndicatorProfessorName.تعداد_جلسات_برگزار_شده_کلاس));
            var scores7 = indicator7.Scores;

            foreach (var c in listOfClass)
            {
                if (obj.HoldingExamDate == null)
                {
                    listOfCountClass.Add(((scores7.FirstOrDefault(p => p.Point == 80).MinValue.Value) + 1));
                }
                else
                {
                    listOfCountClass.Add(((obj.OnlineHeldingCount ?? 0) + (obj.PersentHeldingCount ?? 0) + (obj.OthersHeldingCount ?? 0)));
                }
            }
            var avg = Math.Round(listOfCountClass.Average(), 0);
            var s   = scores7
                      .FirstOrDefault(p => p.MinValue <= avg &&
                                      p.MaxValue >= avg
                                      );

            if (s != null)
            {
                if (profScore != null && profScore.Id > 0)
                {
                    profScore.Score = s;
                    var point = s.Point * indicator7.Ratio.Point;
                    if (point != null)
                    {
                        profScore.CurrentScore = (int)point;
                    }
                    _professorScoreService.Update(profScore);
                }
                else
                {
                    var point = s.Point * indicator7.Ratio.Point;
                    if (point != null)
                    {
                        var sPoint = (int)point;
                        _professorScoreService.Add(new Model.Models.ProfessorScore
                        {
                            EducationalGroup = obj.EducationalGroup,
                            Professor        = obj.Professor,
                            Term             = currentTerm,
                            Score            = s,
                            CurrentScore     = (int)point
                        });
                    }
                }
            }

            //var scores = _professorScoreService.GetMany(g =>
            //g.Professor.Id == obj.Professor.Id
            //&& g.Term.Id == currentTerm.Id
            //&& g.Score.Indicator.CountOfType == indicatorCountOfTypet).ToList();
            //foreach (var item in scores)
            //{
            //    item.CurrentScore = currentScore;
            //    _professorScoreService.Update(item);
            //}
        }