/// <summary> /// Execute RefreshTablesCommand /// </summary> /// <param name="item">Selected item to be processed.</param> private void ExecuteRefreshTablesCommand(Table item) { try { TableList = new ObservableCollection <Table>(_tableManager.GetList().OrderBy(o => o.State)); } catch (Exception ex) { this.MessageBoxService.ShowError(this.GetType().FullName + System.Reflection.MethodBase.GetCurrentMethod().Name + ": " + ex.Message); } }
public CashierOrdersViewModel(IMessageBoxService messageBoxService, IUIVisualizerService uiVisualizerService, IOrderManager orderManager, ITableManager tableManager, IReportOrderItemEditionManager reportOrderEdition) : base(messageBoxService, uiVisualizerService, orderManager) { // do initialization try { if (tableManager == null) { throw new ArgumentNullException("tableManager"); } _tableManager = tableManager; this.DisplayName = "Orders Management"; TableList = new ObservableCollection <Table>(_tableManager.GetList().OrderBy(o => o.State)); if (reportOrderEdition == null) { throw new ArgumentNullException("reportOrderEdition"); } _reportOrderEdition = reportOrderEdition; // initialize command this.RefreshTablesCommand = new CommandBase <Table>(o => this.ExecuteRefreshTablesCommand(o)); this.ShowCancelledProductCommand = new CommandBase <object>(o => this.ExecuteShowCancelledProductCommand()); this.SelectGroupByCommand = new CommandBase <object>(o => this.ExecuteSelectGroupByCommand()); this.CheckoutCommand = new CommandBase <Order>(o => this.ExecuteCheckoutCommand(o), o => this.CanExecuteCheckoutCommand(o)); this.CancelCommand = new CommandBase <Order>(o => this.ExecuteCancelCommand(o), o => this.CanExecuteCancelCommand(o)); this.BillCommand = new CommandBase <Order>(o => this.ExecuteBillCommand(o), o => this.CanExecuteBillCommand(o)); this.PrintCommand = new CommandBase <Order>(o => this.ExecutePrintCommand(o), o => this.CanExecutePrintCommand(o)); this.SelectDiscountCommand = new CommandBase <Order>(o => this.ExecuteSelectDiscountCommand(o), o => this.CanExecuteSelectDiscountCommand(o)); this.ServiceChargeCommand = new CommandBase <Order>(o => this.ExecuteServiceChargeCommand(o), o => this.CanExecuteServiceChargeCommand(o)); this.EnableVatCommand = new CommandBase <Order>(o => this.ExecuteEnableVatCommand(o), o => this.CanExecuteEnableVatCommand(o)); // available discount list DiscountList = new List <Discount>(); DiscountList.Add(new Discount("0%", 0)); DiscountList.Add(new Discount("5%", 5)); DiscountList.Add(new Discount("10%", 10)); DiscountList.Add(new Discount("15%", 15)); DiscountList.Add(new Discount("20%", 20)); DiscountList.Add(new Discount("25%", 25)); DiscountList.Add(new Discount("30%", 30)); GroupByList.Add(new ReportGroupBy("Thu tu goi", "EditionInfo")); GroupByList.Add(new ReportGroupBy("Mon an", "ProductName")); SelectedGroupBy = GroupByList[0]; //Mediator.Instance.RegisterHandler<T>("Updated" + typeof(T).Name + "Successfully", HandleReceivedMessage); //Mediator.Instance.RegisterHandler<T>("Created" + typeof(T).Name + "Successfully", HandleReceivedMessage); Mediator.Instance.Register(this); if (SelectedItem != null) { (ModelManager as IOrderManager).FetchOrderItems(SelectedItem); CollectionViewSource.GetDefaultView(SelectedItem.OrderItems).Filter = o => IsShowCancelledProduct || ((OrderItem)o).IsCancelled == false; ReportEditionOrderItemList = _reportOrderEdition.GetEdititonReportOfOrder(SelectedItem); CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(ReportEditionOrderItemList); PropertyGroupDescription groupDescription = new PropertyGroupDescription(SelectedGroupBy.PropertyName); view.GroupDescriptions.Clear(); view.GroupDescriptions.Add(groupDescription); } } catch (Exception ex) { this.MessageBoxService.ShowError(this.GetType().FullName + System.Reflection.MethodBase.GetCurrentMethod().Name + ": " + ex.Message); } }