public SectionVM GetBy(string urlName, int?id) { var section = urlName.IsEmpty() ? SectionService.GetByPK(id) : SectionService.GetAll().ByUrlName(urlName); if (section == null) { return(null); } var sectionIdsContainUserWorks = GetSectionIdsContainUserWorks(); var entityWithTags = EntityCommonService.GetEntityWithTags(section); AddMicrosoft(section, entityWithTags); var parent = SectionService.GetSectionsTree() .FirstOrDefault(z => z.SubSections .Any(x => x.Section_ID == section.Section_ID)); return (new SectionVM { Section = section, Parent = parent, EntityWithTags = entityWithTags, SectionIdContainUserWorks = sectionIdsContainUserWorks, }); }
int GetRootSectionId(int sectionId) { var tree = SectionService.GetSectionsTree(); return(tree.FirstOrDefault(x => x.Section_ID == sectionId || x.SubSections.Any(y => y.Section_ID == sectionId)) .GetOrDefault(x => x.Section_ID)); }
private IEnumerable <Grouping <Section, string> > GetSectionWithCourses() { var rootSections = SectionService.GetSectionsTree(); return(rootSections.Select(s => Grouping.New(s, CourseService.GetCourseTCListForSections(_.List(s.Section_ID) .AddFluent(s.SubSections.Select(x => x.Section_ID)))))); }
public GroupListVM GetAllGroups(GroupFilter filter, int pageIndex) { var cityTC = UserSettingsService.CityTC; var leftBeginDate = filter.BeginDate; var rightBeginDate = filter.EndDate; var courseTCs = new List <string>(); if (!filter.CourseTC.IsEmpty()) { courseTCs.Add(filter.CourseTC); } else { if (filter.SectionId.HasValue) { var mainSection = SectionService.GetSectionsTree() .FirstOrDefault(x => x.Section_ID == filter.SectionId.Value); var sectionIds = new List <int>(); if (mainSection != null && mainSection.SubSections.Any()) { sectionIds = mainSection.SubSections.Select(x => x.Section_ID).ToList(); } else { sectionIds.Add(filter.SectionId.Value); } courseTCs.AddRange(CourseService.GetCourseTCListForSections(sectionIds)); } } var groupQuery = GroupService.GetGroupsForCourse(courseTCs, cityTC, leftBeginDate, rightBeginDate, filter.DayShiftTC, filter.ComplexTC, filter.DaySequenceTC); switch (filter.StudyTypeId) { case GroupFilter.StudyType.Intramural: groupQuery = groupQuery.Where(x => !x.ForWebinarOnly); break; case GroupFilter.StudyType.Webinar: groupQuery = groupQuery.Where(x => x.WebinarExists); break; case GroupFilter.StudyType.OpenLearning: groupQuery = groupQuery.Where(x => x.MegaGroup_ID != null); break; case GroupFilter.StudyType.IntraExtra: groupQuery = groupQuery.Where(x => x.IsIntraExtramural); break; } if (!filter.EmployeeTC.IsEmpty()) { groupQuery = groupQuery.Where(x => x.Teacher_TC == filter.EmployeeTC); } groupQuery = groupQuery.NotSpecial(); var groups = groupQuery.ToPagedList(pageIndex); var result = new GroupListVM { Groups = groups, Filter = filter, }; if (!filter.CourseTC.IsEmpty()) { var course = CourseService.GetByPK(filter.CourseTC); filter.CourseName = course.GetOrDefault(x => x.Name); result.Course = course; } return(result); }