async Task ExecuteLoadExpensesCommand() { if (IsBusy) { return; } IsBusy = true; try { Expenses.Clear(); var items = await DraftBudget.GetMonthlyExpensesAsync(true); foreach (var item in items) { Expenses.Add(item); } if (Expenses.Count == 0) { Expenses.Add(new Expense { Id = Guid.NewGuid().ToString(), Title = "", Amount = 0 }); } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
async Task ExecuteLoadDraftData() { if (IsBusy) { return; } IsBusy = true; try { DraftIncome.Clear(); DraftSavings.Clear(); DraftExpenses.Clear(); var items = await DraftBudget.GetIncomeSoursesAsync(true); foreach (var item in items) { DraftIncome.Add(item); } items = await DraftBudget.GetSavingsAsync(true); foreach (var item in items) { DraftSavings.Add(item); } items = await DraftBudget.GetMonthlyExpensesAsync(true); foreach (var item in items) { DraftExpenses.Add(item); } int a = Budget.GetSumOfAllIncome(); int b = Budget.GetSumOfAllSavings(); int c = Budget.GetSumOfAllExpenses(); IncomeSum = "Total Income: " + a.ToString(); SavingsSum = "Total Savings: " + b.ToString(); ExpensesSum = "All Monthly Expenses: " + c.ToString(); Remainder = "Your remaining monthly budget: " + (a - b - c).ToString(); } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }