private void PopulateCategories(CategoriesViewModel categories) { Categories = new ObservableCollection <BudgetCategoryViewModel>(); foreach (var category in categories.Categories) { if (!string.IsNullOrEmpty(category.Name)) { Categories.Add(new BudgetCategoryViewModel(category.Id, category.Name)); } } }
public ExpensesViewModel(DataLoader dataLoader, Auditor auditor, DateStateViewModel dateState, CategoriesViewModel categoriesMap) : base(dataLoader, auditor, dateState) { Transactions = new ObservableCollection <TransactionViewModel>(); HandleExpenseTransactions(dataLoader); HandleAccountsLoading(); TransactionsView = CollectionViewSource.GetDefaultView(Transactions); TransactionsView.Filter = TransactionsFilter; TransactionsView.SortDescriptions.Add(new SortDescription("Date", ListSortDirection.Descending)); CategoriesMap = categoriesMap; }
public TransactionViewModel(ITransaction transaction) { Id = transaction.EventId; AccountId = transaction.AccountId; Date = transaction.EventDate; Description = transaction.EventDescription; Amount = transaction.EventAmount; Balance = transaction.CurrentBalance; Type = transaction.Type; SupplierId = Convert.ToInt64(transaction.SupplierId); IsActive = InactiveTransactionsManager.IsActive(Id); ParentId = 0; Category = CategoriesViewModel.GetCategoryBySupplier(SupplierId); CategoriesViewModel.WhenCategoryUpdated.Subscribe((changedCategory) => { if (SupplierId == changedCategory.Supplier) { Category = changedCategory.Category.Id; } }); }
public BudgetViewModel(DataLoader dataLoader, Auditor auditor, DateStateViewModel dateState, CategoriesViewModel categories) : base(dataLoader, auditor, dateState) { Transactions = new ObservableCollection <TransactionViewModel>(); CreateCommands(); PopulateCategories(categories); HandleExpenseTransactions(dataLoader); TransactionsView = CollectionViewSource.GetDefaultView(Transactions); TransactionsView.Filter = TransactionsFilter; TransactionsView.SortDescriptions.Add(new SortDescription("Date", ListSortDirection.Descending)); }