Exemple #1
0
        public Dictionary <string, decimal> GetTotalFlowPerCategoriesForMonth(DateTime month)
        {
            var categoryTotals = new Dictionary <string, decimal>
            {
                { "Total Expenses", GetTotalExpenseForMonth(month) }
            };

            categoryTotals.AddRange(_expenseService.GetAllCategoryTotals(month));

            categoryTotals.Add("Total Income", GetTotalIncomeForMonth(month));
            foreach (var totalIncomeByCategory in _incomeService.GetAllCategoryTotals(month))
            {
                if (categoryTotals.ContainsKey(totalIncomeByCategory.Key))
                {
                    var placeholder = categoryTotals[totalIncomeByCategory.Key];
                    categoryTotals.Remove(totalIncomeByCategory.Key);
                    categoryTotals.Add(string.Format("{0} - Expense", totalIncomeByCategory.Key), placeholder);
                    categoryTotals.Add(string.Format("{0} - Income", totalIncomeByCategory.Key), totalIncomeByCategory.Value);
                }
                else
                {
                    categoryTotals.Add(totalIncomeByCategory.Key, totalIncomeByCategory.Value);
                }
            }

            return(categoryTotals);
        }