Example #1
0
        public void Grouping_GroupBy()
        {
            // Arrange
            var products = FakeProduct.Data.Generate(5);

            // Act
            var result = _grouping.GroupBy(products);

            // see projection
            var allFootballProducts   = result.Where(x => x.Key).SelectMany(x => x);
            var allBasketballProducts = result.Where(x => !x.Key).SelectMany(x => x);

            // Assert
            Assert.True(allFootballProducts.All(x => x.Category == "Football"));
            Assert.True(allBasketballProducts.All(x => x.Category == "Basketball"));
        }
Example #2
0
        private static IEnumerable <TagLi> GroupsBlock(Grouping <Section, Group> groups)
        {
            var courses = groups.GroupBy(x => x.Course_TC).ToList();

            return(courses.Select(c => {
                var course = c.First().Course;
                var maxDiscount = c.Max(x => x.Discount);
                return li.Style("margin:6px 0;")[
                    span[Anchor("/course/" + course.UrlName,
                                course.GetName()).AbsoluteHref(), "<br/>",
                         span.Style("color: rgb(172, 61, 75); font-weight: bold;")[
                             c.OrderBy(x => x.DateBeg)
                             .Select(x => x.DateBeg.NotNullString("dd.MM")).Distinct().JoinWith(", ")],
                         maxDiscount.IfNotNull(d =>
                                               span.Style("color: rgb(172, 61, 75); font-weight: bold;")[
                                                   (c.Count() == 1 ? " — ñêèäêà {0}%!" :   " — ñêèäêè äî {0}%!").FormatWith(d)])

                    ]];
            }));
        }