public void setBalance() { var firstDayOfMonth = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1); var lastDayOfMonth = firstDayOfMonth.AddMonths(1).AddSeconds(-1); MonthBalance = 0; ExpensesValue = 0; var iexpenseList = expenseRep.GetExpensesAsync().Result; var ibudgetList = budgetRep.GetBudgetsAsync().Result; foreach (Expense i in iexpenseList) { if (i.Date >= firstDayOfMonth && i.Date <= lastDayOfMonth) { ExpensesValue += i.Value; } } foreach (Budget i in ibudgetList) { if (i.Date == firstDayOfMonth) { MonthBalance = i.MonthlyBudget - ExpensesValue; isBalanceSet = true; break; } } }
public void ExpensesList() { ExtendedExpenseList = new List <ExtendedExpense>(); dateList = new List <DateTime>(); CategoryList = new List <String>(); var iList = expenseRep.GetExpensesAsync(); var CatList = categoryRep.GetCategoriesAsync(); foreach (Category i in CatList.Result) { CategoryList.Add(i.CategoryTitle); } foreach (Expense i in iList.Result.OrderByDescending(i => i.Date)) { if (!dateList.Contains(new DateTime(i.Date.Year, i.Date.Month, 1))) { dateList.Add(new DateTime(i.Date.Year, i.Date.Month, 1)); } ExtendedExpenseList.Add(new ExtendedExpense { Expense = i, Category = CategoryList.ElementAt(i.CategoryId - 1) }); } }
public async Task MakeExpenseList() { ExtendedExpenseList = new ObservableCollection <ExtendedExpense>(); CategoryList = new List <String>(); var iList = await expenseRep.GetExpensesAsync(); var CatList = await categoryRep.GetCategoriesAsync(); foreach (Category i in CatList) { CategoryList.Add(i.CategoryTitle); } foreach (Expense i in iList) { ExtendedExpenseList.Add(new ExtendedExpense { Expense = i, Category = CategoryList.ElementAt(i.CategoryId - 1) }); } }