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); }
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); } }); }