コード例 #1
0
        private string GetGroupsBlock(bool isBest, string courseTCs)
        {
            List <Group> groups;
            List <Grouping <Section, Group> > sectionGroups;

            if (!courseTCs.IsEmpty())
            {
                groups        = GetForUnsplitCourseTCList(courseTCs);
                sectionGroups = _.List(Grouping.New(new Section(), groups));
            }
            else if (isBest)
            {
                groups = GetPlannedGroups()
                         .Where(x => courseList.Contains(x.Course_TC) && x.Discount.HasValue)
                         .ToList();
                sectionGroups = _.List(Grouping.New(new Section(), groups));
            }
            else
            {
                groups = GroupService.GetAll(x => x.DateBeg > DateTime.Today.AddDays(1) &&
                                             x.DateBeg <= DateTime.Today.AddDays(30) && x.Discount.HasValue)
                         .PlannedAndNotBegin().ToList();
                sectionGroups = GroupVMService.GetSectionGroups(groups);
            }

            return(l(
                       sectionGroups.OrderBy(x => x.Key.WebSortOrder)
                       .Select(x => l(h3[x.Key.Name],
                                      ul.Style("list-style-type:square;font-size:13px;")[
                                          GroupsBlock(x)]
                                      ).ToString()).JoinWith("")).ToString());
        }
コード例 #2
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))))));
        }
コード例 #3
0
        public List <Grouping <Section, string> > GetSectionCourseTCs(IEnumerable <string> courseTCs)
        {
            var sectionWithCourses = GetSectionWithCourses();

            return(sectionWithCourses.Select(s =>
                                             Grouping.New(s.Key,
                                                          courseTCs.Where(s.Contains)))
                   .Where(s => s.Any()).ToList());
        }
コード例 #4
0
        public List <Grouping <Section, Course> > GetSectionCourses(IEnumerable <Course> courses)
        {
            var sectionWithCourses = GetSectionWithCourses();

            return(sectionWithCourses.Select(s =>
                                             Grouping.New(s.Key,
                                                          courses.Where(c => s.Contains(c.Course_TC))))
                   .Where(s => s.Any()).ToList());
        }
コード例 #5
0
        public List <IGrouping <Section, IEntityCommonInfo> >[] GetProfessions()
        {
            var sections = Professions.Select(x =>
                                              Grouping.New(x.Entity,
                                                           x.List)).ToList();
            var result = Rotate(sections);

            return(result);
        }
コード例 #6
0
        static void Test()
        {
            var list = _.List <IGrouping <int, int> >(
                Grouping.New(1, Enumerable.Range(0, 6)),
                Grouping.New(2, Enumerable.Range(0, 4)),
                Grouping.New(3, Enumerable.Range(0, 2)),
                Grouping.New(4, Enumerable.Range(0, 8)),
                Grouping.New(5, Enumerable.Range(0, 3)),
                Grouping.New(6, Enumerable.Range(0, 5)));
            var result = list.GetColumns(2, 5);

            WL(result.Select(x => x.Count.ToString()).JoinWith(", "));
        }
コード例 #7
0
        public string Get()
        {
            var context = new SpecialistDataContext();
            var groups  = context.Groups.PlannedAndNotBegin()
                          .Where(g => g.DateBeg > new DateTime(2011, 1, 1))
                          .Select(g => new { g.Course_TC, Date = g.DateBeg.Value, g.Course.Name }).ToList();
            var orgs   = _.List(PriceTypes.Corporate, PriceTypes.CorporateBusinessClass);
            var prices = context.PriceViews.Where(x => orgs.Contains(x.PriceType_TC) &&
                                                  x.Track_TC == null).Select(x =>
                                                                             new { x.Course_TC, x.PriceType_TC, x.Price }).ToList();
            var courses = prices.Select(x => x.Course_TC).Distinct();
            Func <string, string, string> getPrice = (courseTC, priceTypeTC) =>
                                                     prices.FirstOrDefault(p => p.Course_TC == courseTC &&
                                                                           p.PriceType_TC == priceTypeTC).GetOrDefault(x => (decimal?)x.Price)
                                                     .NotNullString("n0");

            groups =
                (from g in groups
                 group g by new { g.Course_TC, Week = GetWeekNumber(g.Date) }
                 into gr
                 select gr.First()).ToList();
            groups = groups.Where(g => courses.Contains(g.Course_TC)).ToList();
            var resultGroups = groups.GroupBy(x => x.Course_TC)
                               .Select(x => new {
                Course_TC = x.Key,
                x.First().Name,
                Dates = x.OrderBy(z => z.Date).Select(z => z.Date.ToString("dd.MM")).JoinWith(" ")
            })
                               .ToList();


            var webcontext   = new SpecialistWebDataContext();
            var rootSections = webcontext.Sections.Where(s => s.IsMain)
                               .ByWebOrder().IsActive().ToList();
            var unity = new UnityContainer();

            UnityRegistrator.RegisterServices(unity);
            var courseService      = unity.Resolve <ICourseService>();
            var sectionWithCourses =
                rootSections.Select(s => new { Section = s, CourseTCs =
                                                   courseService.GetCourseTCListForSections(
                                                       _.List(s.Section_ID)) });

            /*var allSectionCourses = sectionWithCourses
             *      .SelectMany(x => x.CourseTCs).Distinct().ToList();
             * var notInList = resultGroups.Where(g => !allSectionCourses.Contains(g.Course_TC)).ToList();*/
            var groupBySections = sectionWithCourses.Select(s =>
                                                            Grouping.New(s.Section,
                                                                         resultGroups.Where(c => s.CourseTCs.Contains(c.Course_TC))))
                                  .Where(s => s.Any()).ToList();


            return(table[tr[
                             th["Название курса"],
                             th["Цена ОРГ"],
                             th["Цена ОРГБ"],
                             th["Расписание"]],
                         groupBySections.Select(s => H.l(tr[td[s.Key.Name].Colspan(4)],
                                                         s.OrderBy(x => x.Name).Select(g => tr[td[g.Name],
                                                                                               td[getPrice(g.Course_TC, PriceTypes.Corporate)],
                                                                                               td[getPrice(g.Course_TC, PriceTypes.CorporateBusinessClass)],
                                                                                               td[g.Dates]])))].ToString());
        }