public OrderStateButtonViewModel(IEnumerable<Order> selectedOrders, OrderStateGroup stateGroup, OrderState model) { _selectedOrders = selectedOrders; Model = model; OrderStateGroup = stateGroup; if (string.IsNullOrEmpty(model.Name)) model.Name = string.Format("[{0}]", Resources.NewProperty); }
public void UpdateOrderState(OrderStateGroup orderStateGroup, OrderState orderState, int userId) { if (orderStateGroup.Id == OrderStateGroupId && orderState.Name == OrderState && Locked && orderStateGroup.UnlocksOrder) { return; } if (orderState == null || (orderStateGroup.Id == OrderStateGroupId && orderState.Name == OrderState)) { CalculatePrice = true; DecreaseInventory = true; IncreaseInventory = false; OrderState = ""; OrderStateGroupName = ""; OrderStateGroupId = 0; if (orderStateGroup.UnlocksOrder && Id > 0) { Locked = true; } return; } CalculatePrice = orderStateGroup.CalculateOrderPrice; DecreaseInventory = orderStateGroup.DecreaseOrderInventory; IncreaseInventory = orderStateGroup.IncreaseOrderInventory; if (orderStateGroup.UnlocksOrder) { Locked = false; } if (orderStateGroup.AccountTransactionTypeId > 0) { AccountTransactionTypeId = orderStateGroup.AccountTransactionTypeId; } if (IncreaseInventory && Quantity > 0) { Quantity = 0 - Quantity; } if (!IncreaseInventory && Quantity < 0) { Quantity = 0 - Quantity; } OrderState = orderState.Name; OrderStateGroupName = orderStateGroup.Name; OrderStateGroupId = orderStateGroup.Id; }
public OrderStateButton(OrderStateGroup orderStateGroup) { Model = orderStateGroup; Name = Model.ButtonHeader; }
public bool IsStateApplied(OrderStateGroup orderStateGroup) { return(OrderStateGroupId == orderStateGroup.Id); }
private void OnShowOrderStatesExecute(OrderStateGroup orderStateGroup) { var orderStateData = new OrderStateData { SelectedOrders = SelectedOrders, OrderStateGroup = orderStateGroup, Ticket = SelectedTicket }; orderStateData.PublishEvent(EventTopicNames.SelectOrderState); }
private bool CanShowOrderStatesExecute(OrderStateGroup arg) { if (!SelectedOrders.Any()) return false; if (!arg.DecreaseOrderInventory && !arg.IncreaseOrderInventory && SelectedOrders.Any(x => !x.Locked && !x.IsStateApplied(arg))) return false; if (!arg.CalculateOrderPrice && !SelectedTicket.CanRemoveSelectedOrders(SelectedOrders)) return false; if (SelectedOrders.Any(x => !x.DecreaseInventory && !x.IsStateApplied(arg))) return false; return !arg.UnlocksOrder || !SelectedOrders.Any(x => x.Locked && x.OrderStateGroupId == arg.Id); }
public void UpdateOrderState(OrderStateGroup orderStateGroup, OrderState orderState, int userId) { if (orderStateGroup.Id == OrderStateGroupId && orderState.Name == OrderState && Locked && orderStateGroup.UnlocksOrder) return; if (orderState == null || (orderStateGroup.Id == OrderStateGroupId && orderState.Name == OrderState)) { CalculatePrice = true; DecreaseInventory = true; IncreaseInventory = false; OrderState = ""; OrderStateGroupName = ""; OrderStateGroupId = 0; if (orderStateGroup.UnlocksOrder && Id > 0) Locked = true; return; } CalculatePrice = orderStateGroup.CalculateOrderPrice; DecreaseInventory = orderStateGroup.DecreaseOrderInventory; IncreaseInventory = orderStateGroup.IncreaseOrderInventory; if (orderStateGroup.UnlocksOrder) Locked = false; if (orderStateGroup.AccountTransactionTypeId > 0) AccountTransactionTypeId = orderStateGroup.AccountTransactionTypeId; if (IncreaseInventory && Quantity > 0) Quantity = 0 - Quantity; if (!IncreaseInventory && Quantity < 0) Quantity = 0 - Quantity; OrderState = orderState.Name; OrderStateGroupName = orderStateGroup.Name; OrderStateGroupId = orderStateGroup.Id; }
public bool IsStateApplied(OrderStateGroup orderStateGroup) { return OrderStateGroupId == orderStateGroup.Id; }