/// <summary>
 ///     Filter transactions using filter
 /// </summary>
 /// <param name="filter"> filter to be used</param>
 /// <param name="currentUser">guid of logged user profile</param>
 /// <returns>Transaction filling criteria in filter</returns>
 private IQueryable<Transaction> FilterTransactions(
     FilterDataServiceModel filter,
     Guid currentUser)
 {
     return this.GetAccessibleResults(currentUser)
         .Where(
             transaction =>
                 transaction.Date <= filter.EndDate && transaction.Date >= filter.StartDate
                 && (!filter.Budgets.Any() || filter.Budgets.Contains(transaction.Budget.Guid))
                 && (!filter.Wallets.Any() || filter.Wallets.Contains(transaction.Wallet.Guid))
                 && (!filter.Categories.Any() || filter.Categories.Contains(transaction.Category.Guid))
         ).OrderBy(transaction => transaction.Date);
 }
 public DashBoardServiceModel()
 {
     Filter = new FilterDataServiceModel();
     Transactions = Enumerable.Empty<Transaction>();
 }
 /// <summary>
 ///     Filter transactions using filter
 /// </summary>
 /// <param name="mappedFilter"> filter to be used</param>
 /// <param name="userId">guid of logged user profile</param>
 /// <returns>DashBoardServiceModel filled with graphs transactions and other data </returns>
 public async Task<DashBoardServiceModel> GenerateDataForFilter(FilterDataServiceModel mappedFilter, Guid userId)
 {
     // select transactions according to filter
     var userWallet = await this.GetWalletByUserId(userId);
     var resultMonth = this.FilterTransactions(mappedFilter.WithMonthFilterValues(), userId);
     var resultYear = this.FilterTransactions(mappedFilter.WithYearFilterValues(), userId);
     // prepare data for graphs
     var categoriesExpense =
         await
             this.GetWrapperValuesForCategories(resultMonth.Where(transaction => transaction.Amount < 0),
                 userWallet.Currency);
     var categoriesIncome =
         await
             this.GetWrapperValuesForCategories(resultMonth.Where(transaction => transaction.Amount >= 0),
                 userWallet.Currency);
     var monthSummary = await this.GetGraphForDaysLastMonth(resultMonth, userWallet.Currency);
     var yearSummary = await this.GetGraphForMonthLastYear(resultYear, userWallet.Currency);
     // generate charts
     return new DashBoardServiceModel
     {
         CategoriesExpenseChart = this.GeneratePieChart(categoriesExpense),
         CategoriesIncomeChart = this.GeneratePieChart(categoriesIncome),
         MonthSummaryChart = this.GenerateLineChart(monthSummary),
         YearSummaryChart = this.GenerateLineChart(yearSummary),
         Transactions = await this.LastTransactions(resultYear),
         BudgetLimitChart = await this.CreateChartForBudgetLimits(userId, userWallet.Currency)
     };
 }