public AddExpenseViewModel(int userId) { CategoryDetailsDAL categoryDetailsDAL = new CategoryDetailsDAL(); this.UserId = userId; AddExpenseCommand = new AddExpenseCommand(this); AddExpenseCancelCommand = new AddExpenseCancelCommand(this); LogoutCommand = new LogoutCommand(); Categories = new ObservableCollection <CategoryDetails>(categoryDetailsDAL.GetCategories()); }
public List <Bar> MappingOfBarValues(int userId) { CategoryDetailsDAL categoryDetailsDAL = new CategoryDetailsDAL(); var categoryList = categoryDetailsDAL.GetCategories(); ExpenseDetailsDAL expenseDetailsDAL = new ExpenseDetailsDAL(); var expenses = expenseDetailsDAL.GetExpenses(userId); List <Bar> _bar = new List <Bar>(); foreach (var category in categoryList) { var value = expenses.Where(x => x.CategoryId == category.CategoryId).Select(x => x.Amount).Sum(); _bar.Add(new Bar() { BarName = category.CategoryName, Value = value }); } return(_bar); }