public MainViewModel(IDataManager dataManager, IBroadcaster broadcaster) { _dataManager = dataManager; _broadcaster = broadcaster; _addNewBudgetCommand = new RelayCommandAsync(AddNewBudget); _initialBudgetUpdateCommand = new RelayCommand(UpdateInitialBudgetValue) { IsEnabled = true }; _broadcaster.Event <BudgetUpdatedEvent>().Subscribe(OnBudgetUpdated); }
public async override Task LoadData(object arg) { _currentBudget = arg as Budget; _currentBudget.LastUpdated = DateTime.Now; await _dataManager.UpdateObject(_currentBudget); _broadcaster.Event <BudgetUpdatedEvent>().Broadcast(_currentBudget); await _dataManager.GetBudgetSections(_currentBudget); if (_currentBudget.Sections != null) { BudgetSections = new ObservableCollection <BudgetSection>(_currentBudget.Sections); } TotalCollection = new ObservableCollection <TotalData>(); if (_currentBudget.HasInitialBudget) { InitialBudget = new TotalData() { Title = "Initial Budget", Value = _currentBudget.InitialBudget, ValueConverted = (decimal)(_currentBudget.InitialBudget / 2.20m) }; TotalCollection.Add(InitialBudget); MoneyLeft = new TotalData() { Title = "Money Left" }; TotalCollection.Add(MoneyLeft); } Totals = new TotalData() { Title = "Total" }; TotalCollection.Add(Totals); Recalculate(); }