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);
 }
Exemplo n.º 2
0
 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;
 }
Exemplo n.º 3
0
 public OrderStateButton(OrderStateGroup orderStateGroup)
 {
     Model = orderStateGroup;
     Name = Model.ButtonHeader;
 }
Exemplo n.º 4
0
 public bool IsStateApplied(OrderStateGroup orderStateGroup)
 {
     return(OrderStateGroupId == orderStateGroup.Id);
 }
Exemplo n.º 5
0
 private void OnShowOrderStatesExecute(OrderStateGroup orderStateGroup)
 {
     var orderStateData = new OrderStateData
                            {
                                SelectedOrders = SelectedOrders,
                                OrderStateGroup = orderStateGroup,
                                Ticket = SelectedTicket
                            };
     orderStateData.PublishEvent(EventTopicNames.SelectOrderState);
 }
Exemplo n.º 6
0
 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);
 }
Exemplo n.º 7
0
 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;
 }
Exemplo n.º 8
0
 public bool IsStateApplied(OrderStateGroup orderStateGroup)
 {
     return OrderStateGroupId == orderStateGroup.Id;
 }