Exemplo n.º 1
0
        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,
            });
        }
Exemplo n.º 2
0
        public List <string> GetCourseTCListForTotalSection(int sectionId)
        {
            var sectionIds = _.List(sectionId)
                             .AddFluent(SectionService.GetChildren(sectionId).Select(x => x.Section_ID));

            return(CourseService.GetCourseTCListForSections(sectionIds));
        }
Exemplo n.º 3
0
        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));
        }
Exemplo n.º 4
0
        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))))));
        }
Exemplo n.º 5
0
 public List <string> CoursesForInvoice()
 {
     return(MethodBase.GetCurrentMethod().Cache(() => {
         var sectionIds = SectionService.GetTreeWithSubsections()
                          .Where(x => Sections.ForInvoice.Contains(x.Section_ID))
                          .SelectMany(x => x.SubSections).Select(x => x.Section_ID).ToList();
         return CourseService.GetCourseTCListForSections(sectionIds);
     }));
 }
Exemplo n.º 6
0
        GetSectionWithEntityTree()
        {
            var mainSections = SectionService.GetAll(x => x.IsMain && x.IsActive)
                               .OrderBy(x => x.WebSortOrder).ToList();

            return(mainSections.Select(x => EntityWithList.New((IEntityCommonInfo)x,
                                                               SiteObjectRelationService.GetMenuTree(x).Select(e => e.Entity)
                                                               .Where(e => e is Section || e.As <IForMainPage>()
                                                                      .GetOrDefault(z => z.ForMainPage)))).ToList());
        }
Exemplo n.º 7
0
        private Tuple <List <string>, List <decimal> > FilterCourses(int sectionId, List <string> courseTCs)
        {
            var notAnnounce = SectionService.NotAnnounce()
                              .GetValueOrDefault(sectionId) ?? new List <string>();
            var groupIds = StringUtils.IntList(notAnnounce).Select(x => (decimal)x).ToList();

            if (!groupIds.Any())
            {
                courseTCs = courseTCs.Except(notAnnounce).ToList();
            }
            return(Tuple.Create(courseTCs, groupIds));
        }
Exemplo n.º 8
0
        public List <Announce> GetHotGroupsForSection(Section section)
        {
            var sections = _.List(section).AddFluent(
                SectionService.GetChildren(section.Section_ID));
            var announces = new List <Announce>();

            foreach (var subSection in sections)
            {
                if (announces.Count >= CommonConst.AnnounceCount)
                {
                    break;
                }
                announces.AddRange(GetAllFor(subSection)
                                   .Take(CommonConst.AnnounceCount - announces.Count));
            }
            return(announces);
        }
Exemplo n.º 9
0
        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);
        }