Exemple #1
0
        public ActionResult SectionTrainers(string urlName)
        {
            var section = SectionService.GetAll().ByUrlName(urlName);

            if (section == null)
            {
                return(null);
            }
            var courseTCs = CourseVMService
                            .GetCourseTCListForTotalSection(section.Section_ID);

            var groups = GroupService.GetGroupsForCourses(courseTCs)
                         .Where(g => g.Teacher_TC != null).ToList();
            var groupCountByTrainers = groups.GroupBy(x => x.Teacher_TC)
                                       .ToDictionary(x => x.Key, x => x.Count());
            var trainers = groups
                           .Select(x => x.Teacher)
                           .Distinct(x => x.Employee_TC)
                           .Select(x => new { Teacher = x,
                                              Count   = groupCountByTrainers.GetValueOrDefault(x.Employee_TC) })
                           .Where(x => x.Teacher.FinalSiteVisible && x.Count > 0)
                           .OrderByDescending(x => x.Count).Select(x => x.Teacher)
                           .ToList();

            return(View(ViewNames.Trainers, CommonVM.New(trainers, "Преподаватели направления: " + section.Name)));
        }