public MainWindowViewModel(DatabaseContext dc, IEventAggregator ea, IRegionManager regionManager) : base(dc, ea) { // Registering Regions regionManager.RegisterViewWithRegion("SalesRegion", typeof(Sales)); regionManager.RegisterViewWithRegion("CashRegion", typeof(Cash)); regionManager.RegisterViewWithRegion("ArticlesRegion", typeof(Articles)); regionManager.RegisterViewWithRegion("ReportRegion", typeof(Report)); Ea.GetEvent <ValidationEvent>().Subscribe(ValidationEventHandler); AboutCommand = new DelegateCommand(ShowAboutMessage); SaveCommand = new DelegateCommand(OnSave, CanSave); ExitCommand = new DelegateCommand(OnExit); //Dc.ChangeTracker.StateChanged += StateChangedHandler; }
public CashViewModel(DatabaseContext db, IEventAggregator ea) : base(db, ea) { Ea.GetEvent <DateSelectedChangedEvent>().Subscribe(DateSelectedChangedHandler); Sales = Dc.Sales.Local.ToObservableCollection(); Deposits = Dc.Deposits.Local.ToObservableCollection(); DepositsCollectionView = CollectionViewSource.GetDefaultView(Deposits); DepositsCollectionView.Filter += new Predicate <object>(DepositsViewFilterHandler); DepositsCollectionView.CurrentChanged += DepositsCollectionView_CurrentChanged; CreateSaleDailyCollection(SalesDaily, Sales); SalesDailyCollectionView = CollectionViewSource.GetDefaultView(SalesDaily); SalesDailyCollectionView.Filter += new Predicate <object>(SalesDailyViewFilterHandler); // DEPOSITS // 1. register for PropertyChanged event for all existing items in Deposits foreach (var item in Deposits) { item.PropertyChanged += Deposit_PropertyChanged; } // 2. for all items which are going to be removed or added to Deposits Deposits.CollectionChanged += Deposits_CollectionChanged; // ORDERS // 1. register for PropertyChanged event for all existing items in Orders foreach (var item in Sales) { item.PropertyChanged += Sale_PropertyChanged; } // 2. for all items which are going to be removed or added to Orders Sales.CollectionChanged += Sales_CollectionChanged; AddNewDepositCommand = new DelegateCommand(AddNewDeposit); RemoveDepositCommand = new DelegateCommand <object>(RemoveDeposit, CanRemoveDeposit); }