Beispiel #1
0
        public ExpenseTransactionsViewModel MapExpenseTransactionsViewModel(int id)
        {
            var transactions = FinancialPlannerRepository.GetTransactions()
                               .Where(m => m.ExpenseId == id).ToList();

            var vm = new ExpenseTransactionsViewModel
            {
                Transactions = SetViewModelsService.SetTransactionViewModels(transactions)
            };
            var withdrawalAmount = transactions.Where(m => m.IsWithdrawal).Sum(m => m.Amount);
            var depositAmount    = transactions.Where(m => !m.IsWithdrawal).Sum(m => m.Amount);

            vm.Total = depositAmount - withdrawalAmount;

            return(vm);
        }
        public BudgetItemTransactionViewModel MapBudgetItemTransactionViewModel(int id)
        {
            var transactions = FinancialPlannerRepository.GetTransactions()
                               .Where(m => m.BudgetItemId == id).ToList();

            var withdrawalAmount = transactions.Where(m => m.IsWithdrawal).Sum(m => m.Amount);
            var depositAmount    = transactions.Where(m => !m.IsWithdrawal).Sum(m => m.Amount);

            var transactionTotal = depositAmount - withdrawalAmount;

            var vm = new BudgetItemTransactionViewModel
            {
                BudgetItemTransactions = SetViewModelsService.SetTransactionViewModels(transactions),
                BudgetItemId           = id,
                TransactionTotal       = transactionTotal
            };

            return(vm);
        }