Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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());
            }
        }
Esempio n. 3
0
        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());
            }
        }
Esempio n. 4
0
        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;
        }
Esempio n. 5
0
 private void SetupItemSectionChange(BudgetItem arg)
 {
     ItemSectionChangeList   = BudgetSections.ToDictionary(k => k, v => arg);
     _isItemSectionChangeSet = true;
 }