public OrderViewModel(IMessageBoxService messageBoxService, IOrderManager manager, ITableManager tableManager) : base(messageBoxService, manager) { // do initialization try { if (tableManager == null) { throw new ArgumentNullException("tableManager"); } _tableManager = tableManager; // populate the list of tables this.FreeTableList = _tableManager.GetFreeTables(); _productGroupManager = new ProductGroupManager(); this.ProductGroupList = _productGroupManager.GetList(); // add one item, in case user select all group this.ProductGroupList.Insert(0, new ProductGroup { Id = -1, Code = "ALL", Name = "All", Description = "List of all products" }); _productManager = new ProductManager(); this.AvailableProductList = _productManager.GetList(); // initialize command this.AddOrderItemCommand = new CommandBase <Product>(o => this.ExecuteAddOrderItemCommand(o), o => this.CanExecuteAddOrderItemCommand(o)); this.CancelOrderItemCommand = new CommandBase <OrderItem>(o => this.ExecuteCancelOrderItemCommand(o), o => this.CanExecuteCancelOrderItemCommand(o)); this.UnCancelOrderItemCommand = new CommandBase <OrderItem>(o => this.ExecuteUnCancelOrderItemCommand(o), o => this.CanExecuteUnCancelOrderItemCommand(o)); this.IncreaseQuantityCommand = new CommandBase <OrderItem>(o => this.ExecuteIncreaseQuantityCommand(o), o => this.CanExecuteIncreaseQuantityCommand(o)); this.DecreaseQuantityCommand = new CommandBase <OrderItem>(o => this.ExecuteDecreaseQuantityCommand(o), o => this.CanExecuteDecreaseQuantityCommand(o)); this.SelectProductGroupCommand = new CommandBase <ProductGroup>(o => this.ExecuteSelectProductGroupCommand(o), o => this.CanExecuteSelectProductGroupCommand(o)); this.ShowCancelledProductCommand = new CommandBase <object>(o => this.ExecuteShowCancelledProductCommand()); this.DisplayName = "Create Order"; // temporarily Item.CreatorId = GlobalObjects.SystemUser.Id; Item.CreatorUser = GlobalObjects.SystemUser; } catch (Exception ex) { this.MessageBoxService.ShowError(this.GetType().FullName + System.Reflection.MethodBase.GetCurrentMethod().Name + ": " + ex.Message); } }
public OrderViewModel(IMessageBoxService messageBoxService, Order item, IOrderManager manager, ITableManager tableManager) : base(messageBoxService, item, manager) { // do initialization try { if (tableManager == null) { throw new ArgumentNullException("tableManager"); } _tableManager = tableManager; // populate the list of tables this.FreeTableList = _tableManager.GetFreeTables(); // aslo need add current table into top of free table list this.FreeTableList.Insert(0, this.Item.Table); _productGroupManager = new ProductGroupManager(); this.ProductGroupList = _productGroupManager.GetList(); // add one item, in case user select all group this.ProductGroupList.Insert(0, new ProductGroup { Id = -1, Code = "ALL", Name = "All", Description = "List of all products" }); _productManager = new ProductManager(); this.AvailableProductList = _productManager.GetList(); // initialize command this.AddOrderItemCommand = new CommandBase <Product>(o => this.ExecuteAddOrderItemCommand(o), o => this.CanExecuteAddOrderItemCommand(o)); this.CancelOrderItemCommand = new CommandBase <OrderItem>(o => this.ExecuteCancelOrderItemCommand(o), o => this.CanExecuteCancelOrderItemCommand(o)); this.UnCancelOrderItemCommand = new CommandBase <OrderItem>(o => this.ExecuteUnCancelOrderItemCommand(o), o => this.CanExecuteUnCancelOrderItemCommand(o)); this.IncreaseQuantityCommand = new CommandBase <OrderItem>(o => this.ExecuteIncreaseQuantityCommand(o), o => this.CanExecuteIncreaseQuantityCommand(o)); this.DecreaseQuantityCommand = new CommandBase <OrderItem>(o => this.ExecuteDecreaseQuantityCommand(o), o => this.CanExecuteDecreaseQuantityCommand(o)); this.SelectProductGroupCommand = new CommandBase <ProductGroup>(o => this.ExecuteSelectProductGroupCommand(o), o => this.CanExecuteSelectProductGroupCommand(o)); this.ShowCancelledProductCommand = new CommandBase <object>(o => this.ExecuteShowCancelledProductCommand()); this.DisplayName = "Edit Order: " + this.Item.Table.Name; CollectionViewSource.GetDefaultView(Item.OrderItems).Filter = o => IsShowCancelledProduct || ((OrderItem)o).IsCancelled == false || (((OrderItem)o).IsCancelled == true && ((OrderItem)o).IsDirty == true); //if (GlobalObjects.SystemUser.StartEditOrder(Item)) //{ } if (Item.LockState == false) { // lock order, prevent other user editting order. Item.LockKeeperId = GlobalObjects.SystemUser.Id; Item.LockKeeper = GlobalObjects.SystemUser; // below code will do inside lock function //Item.LockState = true; (ModelManager as IOrderManager).Lock(Item); } } catch (Exception ex) { this.MessageBoxService.ShowError(this.GetType().FullName + System.Reflection.MethodBase.GetCurrentMethod().Name + ": " + ex.Message); } }