コード例 #1
0
        // GET: MonthlyBudgetBoard/Details/5
        public async Task <IActionResult> Details(int id)
        {
            var result = await _monthlyBudgetService.GetMonthlyBudgetBoardById(id);

            var expenses = await _monthlyBudgetService.GetExpenseTypes();

            var budgetBoard = await _budgetBoardService.GetBudgetBoardById(result.BudgetBoardId);

            var expenseTypeList     = new SelectList(expenses, "ExpenseTypeId", "ExpenseTypeName");
            var expenseTotal        = 0.0;
            var livingExpenseTotal  = 0.0;
            var leisureExpenseTotal = 0.0;

            foreach (var expense in result.ExpenseList)
            {
                expenseTotal += expense.ExpenseAmount;

                if (expense.ExpenseTypeId == 1)
                {
                    livingExpenseTotal += expense.ExpenseAmount;
                }

                else if (expense.ExpenseTypeId == 3)
                {
                    leisureExpenseTotal += expense.ExpenseAmount;
                }
            }
            ;

            ViewBag.expenseTotal = expenseTotal;
            ViewBag.ExpenseType  = expenseTypeList;

            ViewBag.LeisureAmount = budgetBoard.LeisureAmount;
            ViewBag.SavingsAmount = budgetBoard.SavingsAmount;
            ViewBag.LivingAmount  = budgetBoard.LivingAmount;

            ViewBag.LeisureTotal = leisureExpenseTotal;
            ViewBag.LivingTotal  = livingExpenseTotal;

            return(View(result));
        }
コード例 #2
0
        // GET: BudgetBoard/Details/5
        public async Task <IActionResult> Details(int id)
        {
            var result = await _budgetBoardService.GetBudgetBoardById(id);

            var expenseTotal = 0.0;

            //var livingExpenseTotal = 0.0;
            //var savingsExpenseTotal = 0.0;
            //var leisureExpenseTotal = 0.0;

            foreach (var expense in result.MonthlyExpenses)
            {
                expenseTotal += expense.BillAmount;

                //if (expense.BillType = "Living")
                //{
                //    livingExpenseTotal += expense.BillAmount;
                //}

                //else if (expense.BillType = "Savings")
                //{
                //    savingsExpenseTotal += expense.BillAmount;
                //}

                //else if (expense.BillType = "Leisure")
                //{
                //    leisureExpenseTotal += expense.BillAmount;
                //}
            }

            ViewBag.expenseTotal = expenseTotal;
            //ViewBag.livingExpenseTotal = livingExpenseTotal
            //ViewBag.savingsExpenseTotal = savingsExpenseTotal
            //ViewBag.leisureExpenseTotal = leisureExpenseTotal

            return(View(result));
        }