protected override IEnumerable <CategoryAmount> calculate(FinanceDb db, IQueryable <Transaction> transactions)
        {
            var monthAndCategoryTotals = transactions
                                         .GroupBy(x => new { x.Category, x.Date.Year, x.Date.Month })
                                         .ToList()
                                         .Select(group => new CategoryMonthAmount(group.Key.Category, new MonthAndYear(group.Key.Year, group.Key.Month), group.Sum(x => x.Amount)))
                                         .ToList();
            var data = new AverageOverMonthsCategoryRoller(Category, StartMonth, EndMonth).RollUpByCategoriesOfInterest(db, monthAndCategoryTotals);

            data = filter(data);
            return(data
                   .OrderBy(x => x.Category.Name)
                   .ToList());
        }
        private IEnumerable <CategoryAmount> calculateSelectedMonthData(FinanceDb db)
        {
            var search = new Search()
            {
                DateFrom = SelectedMonth.ToDateTime(MonthAndYear.PositionInMonth.Start),
                DateTo   = SelectedMonth.ToDateTime(MonthAndYear.PositionInMonth.End),
            };
            var selectedMonthTotals = db.Transactions
                                      .Where(search.IsMatch())
                                      .GroupBy(x => x.Category)
                                      .ToList()
                                      .Select(group => new CategoryMonthAmount(group.Key, SelectedMonth, group.Sum(x => x.Amount)));
            var selectedMonthData = new AverageOverMonthsCategoryRoller(Category, SelectedMonth, SelectedMonth)
                                    .RollUpByCategoriesOfInterest(db, selectedMonthTotals)
                                    .ToList();

            return(filter(selectedMonthData));
        }