public CategoryRowViewModel(MasterCategoryRowViewModel masterCategory, Category category, BudgetEditorViewModel budgetEditor)
        {
            InitializeRelayCommands();

            MasterCategory      = masterCategory;
            _category           = category;
            _budgetEditor       = budgetEditor;
            _categoryMonthViews = new TransformingObservableCollection <BudgetMonthViewModel, CategoryMonthViewModel>(
                _budgetEditor.VisibleMonthViews, v =>
            {
                //BudgetMonthView holds it's own copy of the Budget and Categories so you have to match them up based on entityId
                //instead of ReferenceEquals on the instance
                BudgetMonthView view = v.BudgetMonthView;
                MasterCategoryMonthView masterView = view.MasterCategories.Where(mcv => mcv.MasterCategory.EntityID == category.Parent.EntityID).Single();
                var categoryMonthView = masterView.Categories.Where(c => c.Category.EntityID == _category.EntityID).SingleOrDefault();
                if (categoryMonthView != null)
                {
                    return(new CategoryMonthViewModel(v, this, categoryMonthView));
                }
                else
                {
                    return(new CategoryMonthViewModel(v, this, masterView, _category.EntityID));
                }
            },
                cmv =>
            {
                cmv.Dispose();
            });
        }
Esempio n. 2
0
 public MasterCategoryMonthViewModel(BudgetEditorViewModel budgetEditor,
                                     BudgetMonthViewModel budgetMonthViewModel,
                                     MasterCategoryRowViewModel masterCategoryRow,
                                     MasterCategoryMonthView masterCategoryMonthView)
 {
     _budgetEditor           = budgetEditor ?? throw new ArgumentNullException(nameof(budgetEditor));
     _budgetMonthViewModel   = budgetMonthViewModel ?? throw new ArgumentNullException(nameof(budgetMonthViewModel));
     _masterCategoryRow      = masterCategoryRow ?? throw new ArgumentNullException(nameof(masterCategoryRow));
     MasterCategoryMonthView = masterCategoryMonthView ?? throw new ArgumentNullException(nameof(masterCategoryMonthView));
 }
Esempio n. 3
0
 public MasterCategoryMonthViewModel(BudgetEditorViewModel budgetEditor,
                                     BudgetMonthViewModel budgetMonthViewModel,
                                     MasterCategoryRowViewModel masterCategoryRow,
                                     BudgetMonthView budgetMonthView,
                                     string masterCategoryId)
 {
     _budgetEditor         = budgetEditor ?? throw new ArgumentNullException(nameof(budgetEditor));
     _budgetMonthViewModel = budgetMonthViewModel ?? throw new ArgumentNullException(nameof(budgetMonthViewModel));
     _masterCategoryRow    = masterCategoryRow ?? throw new ArgumentNullException(nameof(masterCategoryRow));
     _budgetMonthView      = budgetMonthView ?? throw new ArgumentNullException(nameof(budgetMonthView));
     _masterCategoryId     = masterCategoryId ?? throw new ArgumentNullException(nameof(masterCategoryId));
     RegisterForCallback();
 }
Esempio n. 4
0
        public MasterCategoryRowViewModel(MasterCategory masterCategory, BudgetEditorViewModel budgetEditor)
        {
            _masterCategory           = masterCategory;
            _budgetEditor             = budgetEditor;
            _addCategoryEditor        = new AddCategoryViewModel(this);
            _editMasterCategoryEditor = new EditMasterCategoryViewModel(this);

            if (!_masterCategory.Categories.IsLoaded)
            {
                _masterCategory.Categories.LoadCollection();
            }

            InitializeCategories(masterCategory);

            InitializeMonthViews();
            UpdateIsFirstCategoryRow();
        }
Esempio n. 5
0
        public AddMasterCategoryViewModel(BudgetEditorViewModel budgetEditor)
        {
            _budgetEditor = budgetEditor ?? throw new ArgumentNullException(nameof(budgetEditor));

            AddMasterCategoryCommand = new RelayCommand(AddMasterCategory, CanAddMasterCategory);
        }