Ejemplo n.º 1
0
        public override void ComposeFilters(IEnumerable <User> users)
        {
            var batches = users
                          .SelectMany(u => u.UserCourses.Distinct(new UserCourseComparer()))
                          .Select(u => u.Batch);
            var currUser = users.SingleOrDefault(u => u.UserId == UserSession.CurrentUserId);

            if (currUser != null && currUser.UserCourses.Any())
            {
                var tempShowAll = ShowAll;
                ShowAll = true;
                ComposeFilterItems(batches);
                var batch     = currUser.UserCourses[0].Batch;
                var bactchInt = int.Parse(batch);
                var batch3    = (bactchInt + 2).ToString();
                var batch1    = (bactchInt + 1).ToString();
                var batch2    = (bactchInt - 1).ToString();
                FilterItems = FilterItems
                              .OrderByDescending(f => f.ValueText == batch2)
                              .OrderByDescending(f => f.ValueText == batch3)
                              .OrderByDescending(f => f.ValueText == batch1)
                              .OrderByDescending(f => f.ValueText == batch)
                              .ToList();

                if (!tempShowAll)
                {
                    var finalquery    = FilterItems.Take(_dispFilterCnt);
                    var checkedSkiped = FilterItems.Skip(_dispFilterCnt)
                                        .Where(l => l.IsChecked);
                    finalquery  = finalquery.Concat(checkedSkiped);
                    FilterItems = finalquery.ToList();
                }

                ShowAll       = tempShowAll;
                MasterFilters = FilterItems;
            }
            else
            {
                ComposeFilterItems(batches);
            }
        }