protected virtual void HandleDateStateChange(DateStateViewModel dateState)
 {
     dateState.WhenDateStateChanged.Subscribe((state) =>
     {
         IsLoading = true;
     });
 }
        protected AccountsBaseViewModel(DataLoader dataLoader, Auditor auditor, DateStateViewModel dateState)
        {
            Accounts     = new ObservableCollection <AccountViewModel>();
            AccountsById = new Dictionary <long, AccountViewModel>();
            _auditor     = auditor;
            _dataLoader  = dataLoader;
            _dateStateVm = dateState;

            HandleAuditorNotifications(auditor);
            LoadAccountsFromProfile(dataLoader.ProfileManager.UserProfiles, dataLoader);
            HandleAccountLoading(dataLoader);
            HandleDateStateChange(dateState);

            RemoveAccount = new RelayCommand(a =>
            {
                var accountVm = a as AccountViewModel;
                if (accountVm == null)
                {
                    return;
                }

                Accounts.Remove(accountVm);

                _dataLoader.ProfileManager.RemoveUserAccountProfile(accountVm.ToUserAccountProfile());
            });
        }
Пример #3
0
        public IncomeViewModel(DataLoader dataLoader, Auditor auditor, DateStateViewModel dateState) : base(dataLoader, auditor, dateState)
        {
            Transactions = new ObservableCollection <TransactionViewModel>();

            HandleIncomeTransactions(dataLoader);
            HandleAccountsLoading();

            TransactionsView        = CollectionViewSource.GetDefaultView(Transactions);
            TransactionsView.Filter = TransactionsFilter;
            TransactionsView.SortDescriptions.Add(new SortDescription("Date", ListSortDirection.Descending));
        }
Пример #4
0
 protected override void HandleDateStateChange(DateStateViewModel dateState)
 {
     base.HandleDateStateChange(dateState);
     dateState.WhenDateStateChanged.Subscribe((state) =>
     {
         Transactions.Clear();
         foreach (var category in Categories)
         {
             category.Spent = 0;
         }
     });
 }
Пример #5
0
        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));
        }
Пример #6
0
        private void HandleDateStateChange(DateStateViewModel dateState, DataLoader dataLoader, AccountsViewModel accountsVm)
        {
            dateState.WhenDateStateChanged.Subscribe((state) =>
            {
                var firstDayOfMonth = new DateTime(state.Year, state.Month, 1);
                var lastDayOfMonth  = firstDayOfMonth.AddMonths(1).AddDays(-1);

                foreach (var accountVm in accountsVm.Accounts)
                {
                    dataLoader.LoadAccount(accountVm.Account, firstDayOfMonth, lastDayOfMonth);
                }
            });
        }
Пример #7
0
 protected override void HandleDateStateChange(DateStateViewModel dateState)
 {
     base.HandleDateStateChange(dateState);
     dateState.WhenDateStateChanged.Subscribe((state) =>
     {
         foreach (var accountVm in Accounts)
         {
             accountVm.RemoveAllTransactions();
             if (accountVm.Account != null)
             {
                 accountVm.IsLoading = true;
             }
         }
     });
 }
Пример #8
0
 public AccountsViewModel(DataLoader dataLoader, Auditor auditor, DateStateViewModel dateState) : base(dataLoader, auditor, dateState)
 {
     CreateCommands();
 }
Пример #9
0
 internal DateStateEventArgs(DateStateViewModel dateState)
 {
     DateState = dateState;
 }
Пример #10
0
        public MainViewModel(DataLoader dataLoader, ToolbarViewModel toolbarVm, AccountsViewModel accountsVm, NewAccountViewModel newAccountVm, NewCategoryViewModel newCategoryVm, BudgetViewModel budgetVm, DateStateViewModel dateState)
        {
            Toolbar     = toolbarVm;
            NewAccount  = newAccountVm;
            NewCategory = newCategoryVm;

            accountsVm.WhenShowNewAccountExecuted.Subscribe((e) =>
            {
                ShowAddNewAccountLayout = true;
            });

            budgetVm.WhenShowNewCategoryExecuted.Subscribe((e) =>
            {
                ShowAddNewCategoryLayout = true;
            });

            HandleDateStateChange(dateState, dataLoader, accountsVm);
        }