private async Task ChangeItemSection(KeyValuePair <BudgetSection, BudgetItem> arg) { if (!_isItemSectionChangeSet) { throw new Exception("Item section change is not set!"); } var oldSection = BudgetSections.FirstOrDefault(o => o.BudgetSectionID == arg.Value.BudgetSectionID); await _dataManager.ChangeItemSection(arg.Value, arg.Key, oldSection); }
private async Task RemoveItem(BudgetItem arg) { await _dataManager.RemoveObject(arg); var section = BudgetSections.First(o => o.BudgetSectionID == arg.BudgetSectionID); section.Items.Remove(arg); Recalculate(); if (BudgetItemEdited != null) { BudgetItemEdited(this, new EventArgs()); } }
private async Task AddNewSection(object obj) { if (BudgetSections == null) { BudgetSections = new ObservableCollection <BudgetSection>(); } var section = NewBudgetSection; NewBudgetSection = null; section = await _dataManager.AddSectionToBudget(_currentBudget, section); BudgetSections.Add(section); if (NewBudgetSectionCreated != null) { NewBudgetSectionCreated(this, new EventArgs()); } }
private void Recalculate() { if (BudgetSections == null) { return; } foreach (var section in BudgetSections) { section.RecalculateTotals(); } var total = BudgetSections.Sum(o => o.SectionType == BudgetSectionType.Debit ? o.Total * -1 : o.Total); if (_currentBudget.HasInitialBudget) { MoneyLeft.Value = InitialBudget.Value + total; } Totals.Value = total; }
private void SetupItemSectionChange(BudgetItem arg) { ItemSectionChangeList = BudgetSections.ToDictionary(k => k, v => arg); _isItemSectionChangeSet = true; }