public ExpenseTrackerManagerViewModel(int userId) { this.UserId = userId; this.LogoutCommand = new LogoutCommand(); this.AddExpensePageShowCommand = new AddExpensePageShowCommand(UserId, UserName); ExpenseDetailsDAL expenseDetailsDAL = new ExpenseDetailsDAL(); this.Expenses = new ObservableCollection <ExpenseDetails>(expenseDetailsDAL.GetExpenses(UserId)); this.TempExpenses = Expenses; this.ExpenseFilterCommand = new ExpenseFilterCommand(this); this.EditExpenseCommand = new EditExpenseCommand(this); this.DeleteExpenseCommand = new DeleteExpenseCommand(this); this.ExpenseChartCommand = new ExpenseChartCommand(this); }
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); }
public void Execute(object parameter) { MessageBoxResult result = MessageBox.Show("Do you want to Delete this Expense?", "Confirmation", MessageBoxButton.YesNoCancel, MessageBoxImage.Warning); if (result == MessageBoxResult.Yes) { ExpenseDetailsDAL expenseDetailsDAL = new ExpenseDetailsDAL(); var res = expenseDetailsDAL.DeleteExpense(ExpenseTrackerManagerViewModel.ExpenseDetails.ExpenseTrackerId); if (res) { MessageBox.Show("Expense Deleted Successfully!"); ExpenseTrackerManagerViewModel.Expenses = new ObservableCollection <ExpenseDetails>(expenseDetailsDAL.GetExpenses(ExpenseTrackerManagerViewModel.UserId)); } } else { } }