public MobileTransactionsViewModel(MainViewModel mainViewModel) { _mainViewModel = mainViewModel; FromDateFilter = DateTime.Today.AddDays(-14); ThroughDateFilter = DateTime.Today.AddDays(1); SalesmanFilter = mainViewModel.Context.Salesmen.ToList(); SalesmanFilter.Insert(0, new Salesman { Contragent = new Contragent { LastName = "Any" } }); SelectedSalesmanFilter = SalesmanFilter.FirstOrDefault(); //ClientsFilter = mainViewModel.Context.Clients.ToList().Select(x => x.Contragent).ToList(); //ClientsFilter.Insert(0, new Contragent { LastName = "Any" }); //SelectedClientFilter = ClientsFilter.FirstOrDefault(); ClientsFilter = mainViewModel.Context.Clients.ToList().Select(x => x.Contragent.LastName).ToList(); MobileTransactions = new ObservableCollection <MobileTransactionViewModel>(GetMobileTransactions(mainViewModel.Context)); MobileTransactionsView = CollectionViewSource.GetDefaultView(MobileTransactions); MobileTransactionsView.Filter = Filter; AddCommand = new DelegateCommand(Add); CloseAddDialogCommand = new DelegateCommand(() => AddDialogViewModel = null); DeleteCommand = new DelegateCommand(Delete, () => SelectedTransaction != null); FilterCommand = new DelegateCommand(MobileTransactionsView.Refresh); }
public CashTransactionsViewModel(MainViewModel mainViewModel) { _mainViewModel = mainViewModel; FromDateFilter = DateTime.Today.AddDays(-14); ThroughDateFilter = DateTime.Today.AddDays(1); SalesmanFilter = mainViewModel.Context.Salesmen.ToList(); SalesmanFilter.Insert(0, new Salesman { Contragent = new Contragent { LastName = "Any" } }); SelectedSalesmanFilter = SalesmanFilter.FirstOrDefault(); ContragentsFilter = mainViewModel.Context.Salesmen.Select(x => x.Contragent).ToList(); ContragentsFilter.AddRange(mainViewModel.Context.Guards.Select(x => x.Contragent).ToList()); ContragentsFilter.Insert(0, new Contragent { LastName = "Any" }); SelectedContragentFilter = ContragentsFilter.FirstOrDefault(); TypeFilter = new List <TranType> { TranType.Any, TranType.CashIn, TranType.CashOut, TranType.Coffee, TranType.Salary }; SelectedTypeFilter = TypeFilter.FirstOrDefault(); CashTransactions = new ObservableCollection <CashTransactionViewModel>(GetCashTransactions(_mainViewModel.Context)); CashTransactionsView = CollectionViewSource.GetDefaultView(CashTransactions); CashTransactionsView.Filter = Filter; AddCashTransactionCommand = new DelegateCommand(AddCashTransaction); CloseAddDialogCommand = new DelegateCommand(() => AddCashViewModel = null); PaySalaryCommand = new DelegateCommand(PaySalary); ClosePaySalaryDialogCommand = new DelegateCommand(() => PaySalaryViewModel = null); DeleteCashTransactionCommand = new DelegateCommand(DeleteCashTransaction, () => SelectedCashTransaction != null); FilterCommand = new DelegateCommand(CashTransactionsView.Refresh); }
protected ProductsViewModel(MainViewModel mainViewModel) { MainViewModel = mainViewModel; FromDateFilter = DateTime.Today.AddDays(-14); ThroughDateFilter = DateTime.Today.AddDays(1); CategoryFilter = mainViewModel.Context.Categories.ToList(); CategoryFilter.Insert(0, new Category { Name = "Any" }); SelectedCategoryFilter = CategoryFilter.FirstOrDefault(); SalesmanFilter = mainViewModel.Context.Salesmen.ToList(); SalesmanFilter.Insert(0, new Salesman { Contragent = new Contragent { LastName = "Any" } }); SelectedSalesmanFilter = SalesmanFilter.FirstOrDefault(); OriginFilter = new List <TranType> { TranType.Any, TranType.Bought, TranType.ToRepair, TranType.ToPawn }; SelectedOriginFilter = OriginFilter.FirstOrDefault(); Products = new ObservableCollection <ProductViewModel>(GetProducts(MainViewModel.Context)); ProductsView = CollectionViewSource.GetDefaultView(Products); ProductsView.Filter = Filter; CloseSellProductDialog = new DelegateCommand(() => SellProductDialogViewModel = null); CloseEditProductDialogCommand = new DelegateCommand(() => EditProductDialogViewModel = null); ShowAllTransactionsCommand = new DelegateCommand(ShowAllTransactions); CloseShowAllTransactionsDialogCommand = new DelegateCommand(() => ShowAllTransactionsDialogViewModel = null); FilterCommand = new DelegateCommand(ProductsView.Refresh); }