Beispiel #1
0
        public void EditFinanceItem(FinanceItemViewModel itemVM, bool doNeedToCreateNewPlan)
        {
            if (itemVM.ItemCategory.Id == 0)
            {
                Category newCategory = SaveNewCategory(itemVM.Category);
                itemVM.ItemCategory = newCategory;
            }

            FinanceItemEntity financeItemEntity = itemVM.GetEntity();

            DatabaseHelper.UpdateFinanceItem(financeItemEntity);

            FinanceItem financeItem = AllItems.First(i => i.Id == financeItemEntity.Id);
            if (doNeedToCreateNewPlan)
            {
                var plannedItemViewModel = new PlannedItemViewModel(itemVM.Item)
                {
                    ItemAmount = itemVM.Item.Amount - (itemVM.ItemAmount > 0 ? itemVM.ItemAmount : -itemVM.ItemAmount)
                };
                //TODO: temp fix
                plannedItemViewModel.ItemMilestone = itemVM.ItemMilestone;
                plannedItemViewModel.ItemCategory = itemVM.ItemCategory;

                AddNewFinanceItem(plannedItemViewModel);
            }

            AllItems.Remove(financeItem);
            AllItems.Add(new FinanceItem(financeItemEntity)
            {
                Category = itemVM.Category,
                Milestone = itemVM.Milestone
            });
            OnItemsChanged();
        }
Beispiel #2
0
        public void AddNewFinanceItem(FinanceItemViewModel itemVM)
        {
            if (itemVM.ItemCategory.Id == 0)
            {
                Category newCategory = SaveNewCategory(itemVM.Category);
                itemVM.ItemCategory = newCategory;
            }
            FinanceItemEntity entity = DatabaseHelper.SaveNewFinanceItem(itemVM.GetEntity());

            var financeItem = new FinanceItem(entity)
            {
                Category = itemVM.ItemCategory.Name,
                Milestone = itemVM.ItemMilestone.Name
            };
            AllItems.Add(financeItem);

            OnItemsChanged();
        }