Beispiel #1
0
        public ActionResult EducationalClassesManagement()
        {
            SetViewBag("مدیریت جلسات برگزاری کلاس ها", "EducationalClassesManagement");
            Term selectedTerm = null;

            if (string.IsNullOrEmpty(Request.QueryString["termId"]))
            {
                selectedTerm = GetCurrentTerm();
            }
            else
            {
                var termId = Convert.ToInt32(Request.QueryString["termId"]);
                selectedTerm = _termService.Get(g => g.Id == termId);
            }
            var user    = (Models.User)Session["UserInfo"];
            var groupQS = 0;

            ViewBag.GroupList = new SelectList(_educationalGroupService.GetMany(w => w.Term.Id == selectedTerm.Id).Where(w => !StaticValue.IneligibleEducationalGroupCodes.Contains((int)w.EducationalGroupCode)), "EducationalGroupCode", "Name");
            ViewBag.TermList  = new SelectList(_termService.GetAll().OrderByDescending(o => o.TermCode), "Id", "Name");
            ViewBag.TermId    = selectedTerm.Id;
            if (Request.QueryString["group"] != null && int.TryParse(Request.QueryString["group"], out groupQS))
            {
                TempData["model"]   = _educationalClassService.GetMany(w => w.Term.Id == selectedTerm.Id && w.EducationalGroup.EducationalGroupCode == groupQS).ToList();
                TempData["groupId"] = groupQS;
            }
            if ((user == null || user.EducationalGroupCode == null) && TempData["model"] == null)
            {
                return(View());
            }
            if (TempData["model"] != null)
            {
                var classes = (List <Model.Models.EducationalClass>)TempData["model"];
                ViewBag.GroupId     = TempData["groupId"];
                TempData["model"]   = null;
                TempData["groupId"] = null;
                return(View(classes));
            }
            else
            {
                var groupId = _educationalGroupService.Get(x => x.EducationalGroupCode == user.EducationalGroupCode && x.Term.Id == selectedTerm.Id).Id;
                var classes = _educationalGroupService.Get(g => g.Id == groupId).EducationalClasses.Where(w => w.Term.Id == selectedTerm.Id).ToList();
                return(View(classes));
            }
        }
        public ActionResult RankOfProfessorInEducationalGroup(string id = null, string group = null, string term = null)
        {
            SetViewBag(title: "رتبه بندی اساتید در سطح گروه", menuItem: "RankOfProfessorInEducationalGroup");
            var collegeId = 0;
            var termId    = 0;
            var groupCode = 0;

            ViewBag.CollegeList = new SelectList(_collegeService.GetAll().Where(w => 1 == 2), "Id", "Name", id);
            ViewBag.GroupList   = new SelectList(_educationalGroupService.GetAll().Where(w => 1 == 2), "EducationalGroupCode", "Name", group);
            ViewBag.TermList    = new SelectList(_termService.GetAll().OrderByDescending(o => o.TermCode), "Id", "Name", term);

            if (!string.IsNullOrEmpty(id))
            {
                int.TryParse(id, out collegeId);
            }
            if (!string.IsNullOrEmpty(group))
            {
                int.TryParse(group, out groupCode);
            }
            var user = (Models.User)Session["UserInfo"];

            if (user != null && user.College != null)
            {
                collegeId         = user.College.Id;
                ViewBag.CollegeId = collegeId;
            }
            if (user != null && user.EducationalGroupCode != null)
            {
                groupCode = (int)user.EducationalGroupCode;
            }

            if (!string.IsNullOrEmpty(term) && int.TryParse(term, out termId) && termId > 0 && collegeId > 0 && groupCode > 0)
            {
                var educationalGroup = _educationalGroupService.Get(g => g.EducationalGroupCode == groupCode && g.Term.Id == termId);
                var college          = _collegeService.Get(g => g.Id == collegeId);
                ViewBag.EducationalGroup   = educationalGroup.Name;
                ViewBag.College            = college.Name;
                ViewBag.CollegeId          = college.Id;
                ViewBag.EducationalGroupId = educationalGroup.EducationalGroupCode;
                ViewBag.TermId             = termId;

                //// Old Methode Start
                //var counter = 0;
                //var professors = _educationalGroupService.Get(g => g.Id == groupId).EducationalClasses.Where(w => w.Term.Id == termId).Select(s => s.Professor)
                //    .OrderByDescending(o => o.ProfessorScores.Where(w => w.Term != null && w.Term.Id == termId).Sum(s => s.CurrentScore))
                //    .Select(s => new Models.Professor
                //    {
                //        //Colleges = Mapper.Map<ICollection<Model.Models.College>, ICollection<Models.College>>(s.Colleges),
                //        //EducationalGroups = Mapper.Map<ICollection<Model.Models.EducationalGroup>, ICollection<Models.EducationalGroup>>(s.EducationalGroups),
                //        EducationalClasses = Mapper.Map<ICollection<Model.Models.EducationalClass>, ICollection<Models.EducationalClass>>(s.EducationalClasses),
                //        ProfessorScores = Mapper.Map<ICollection<Model.Models.ProfessorScore>, ICollection<Models.ProfessorScore>>(s.ProfessorScores),
                //        Name = s.Name,
                //        Family = s.Family,
                //        NationalCode = s.NationalCode,
                //        ProfessorCode = s.ProfessorCode,
                //        Gender = Convert.ToBoolean(s.Gender),
                //        RankInUniversity = ++counter
                //    })
                //    .ToList();
                //return View(professors);
                //// Old Methode End
                var collegeList = new List <int>();
                var groupList   = new List <int>();
                collegeList.Add(collegeId);
                groupList.Add(educationalGroup.Id);
                var model = _reportService.GetProfessorReport(termId, collegeList: collegeList, groupList: groupList, allColleges: false, allGroups: false)
                            .General.ToList();
                foreach (var item in model)
                {
                    item.RowNumber = model.IndexOf(item) + 1;
                }
                return(View(model));
            }
            return(View());
        }
        //[HttpPost]
        //public ActionResult EducationalGroupManagerPresenceForAdmin(string college)
        //{
        //    var collegeId = Convert.ToInt32(college);
        //    var groups = _educationalGroupService.GetMany(g => g.College.CollegeCode == collegeId).ToList();
        //    TempData["model"] = groups;
        //    TempData["collegeId"] = collegeId;
        //    return this.Json(string.Empty);
        //}
        public ActionResult EditEducationalGroupManagerPresence()
        {
            var groupId = 0;
            var termId  = 0;

            if (int.TryParse(Request.QueryString["group"], out groupId) && int.TryParse(Request.QueryString["termId"], out termId))
            {
                var group                                = _educationalGroupService.Get(g => g.EducationalGroupCode == groupId && g.Term.Id == termId);
                var onlineIndicator                      = _indicatorService.GetMany(g => g.CountOfType == "g" + (int)IndicatorGroupName.وضعیت_حضور_آنلاین_مدیر_گروه).FirstOrDefault();
                var physicalIndicator                    = _indicatorService.GetMany(g => g.CountOfType == "g" + (int)IndicatorGroupName.وضعیت_حضور_فیزیکی_مدیران_گروه).FirstOrDefault();
                var otherIndicator                       = _indicatorService.GetMany(g => g.CountOfType == "g" + (int)IndicatorGroupName.وضعیت_سایر_جلسات_حضور_مدیر_گروه).FirstOrDefault();
                var onlineHolidaysIndicator              = _indicatorService.GetMany(g => g.CountOfType == "g" + (int)IndicatorGroupName.تعطیلات_رسمی_کلاس_آنلاین_مدیر_گروه).FirstOrDefault();
                var offlineHolidaysIndicator             = _indicatorService.GetMany(g => g.CountOfType == "g" + (int)IndicatorGroupName.تعطیلات_رسمی_کلاس_فیزیکی_مدیر_گروه).FirstOrDefault();
                var educationAndResearchCouncilIndicator = _indicatorService.GetMany(g => g.CountOfType == "g" + (int)IndicatorGroupName.جلسات_شورای_آموزشی_پژوهشی).FirstOrDefault();
                var ol   = onlineIndicator.Scores.ToList();
                var pl   = physicalIndicator.Scores.ToList();
                var othl = otherIndicator.Scores.ToList();
                var onhl = onlineHolidaysIndicator.Scores.ToList();
                var ofhl = offlineHolidaysIndicator.Scores.ToList();
                var erl  = educationAndResearchCouncilIndicator.Scores.ToList();

                if (ol.Count() > 0)
                {
                    ViewBag.OnlineScoreList = new SelectList(ol, "Id", "Name");
                    var currentOnlineScore = GetCurrentRating(groupId, "g" + (int)IndicatorGroupName.وضعیت_حضور_آنلاین_مدیر_گروه, termId) / onlineIndicator.Ratio.Point;
                    if (currentOnlineScore != 0)
                    {
                        ViewBag.OnlineScoreId = ol.FirstOrDefault(f => f.Point == currentOnlineScore).Id;
                    }
                }
                if (pl.Count() > 0)
                {
                    ViewBag.PhysicalScoreList = new SelectList(pl, "Id", "Name");
                    var currentPhysicalScore = GetCurrentRating(groupId, "g" + (int)IndicatorGroupName.وضعیت_حضور_فیزیکی_مدیران_گروه, termId) / physicalIndicator.Ratio.Point;
                    if (currentPhysicalScore != 0)
                    {
                        ViewBag.PhysicalScoreId = pl.FirstOrDefault(f => f.Point == currentPhysicalScore).Id;
                    }
                }
                if (othl.Count() > 0)
                {
                    ViewBag.OtherScoreList = new SelectList(othl, "Id", "Name");
                    var currentOtherScore = GetCurrentRating(groupId, "g" + (int)IndicatorGroupName.وضعیت_سایر_جلسات_حضور_مدیر_گروه, termId) / otherIndicator.Ratio.Point;
                    if (currentOtherScore != 0)
                    {
                        ViewBag.OtherScoreId = othl.FirstOrDefault(f => f.Point == currentOtherScore).Id;
                    }
                }

                if (onhl.Count() > 0)
                {
                    ViewBag.OnlineHolidayScoreList = new SelectList(ol, "Id", "Name");
                    var currentOnlineHolidayScore = GetCurrentRating(groupId, "g" + (int)IndicatorGroupName.تعطیلات_رسمی_کلاس_آنلاین_مدیر_گروه, termId) / onlineHolidaysIndicator.Ratio.Point;
                    if (currentOnlineHolidayScore != 0)
                    {
                        ViewBag.OnlineHolidayScoreId = onhl.FirstOrDefault(f => f.Point == currentOnlineHolidayScore).Id;
                    }
                }
                if (ofhl.Count() > 0)
                {
                    ViewBag.offlineHolidayScoreList = new SelectList(ol, "Id", "Name");
                    var currentOfflineHolidayScore = GetCurrentRating(groupId, "g" + (int)IndicatorGroupName.تعطیلات_رسمی_کلاس_فیزیکی_مدیر_گروه, termId) / offlineHolidaysIndicator.Ratio.Point;
                    if (currentOfflineHolidayScore != 0)
                    {
                        ViewBag.OfflineHolidayScoreId = ofhl.FirstOrDefault(f => f.Point == currentOfflineHolidayScore).Id;
                    }
                }
                if (erl.Count() > 0)
                {
                    ViewBag.EducationalAndResearchCouncilScoreList = new SelectList(ol, "Id", "Name");
                    var currentEducationAndResearchCouncilScore = GetCurrentRating(groupId, "g" + (int)IndicatorGroupName.جلسات_شورای_آموزشی_پژوهشی, termId) / educationAndResearchCouncilIndicator.Ratio.Point;
                    if (currentEducationAndResearchCouncilScore != 0)
                    {
                        ViewBag.EducationAndResearchCouncilId = erl.FirstOrDefault(f => f.Point == currentEducationAndResearchCouncilScore).Id;
                    }
                }

                ViewBag.TermId = Request.QueryString["termId"];
                return(PartialView(group));
            }
            else
            {
                return(null);
            }
        }