Ejemplo n.º 1
0
        private void ConsumeItem(object sender, RoutedEventArgs e)
        {
            var consumedItem = ItemTracker.SelectedItem;

            if (consumedItem.Quantity > 1)
            {
                consumedItem.Quantity -= 1;
                DbTransactionHolder.UpdateEquipmentItemQuantity(UserInventoryView, consumedItem, consumedItem.Quantity);
            }
            else
            {
                UserInventoryView.FullInventoryView.Remove(consumedItem);
                DbTransactionHolder.DeleteEquipmentItem(UserInventoryView, consumedItem);
            }
            DisassemblyButton.Visibility = Visibility.Collapsed;
            ConsumeButton.Visibility     = Visibility.Collapsed;
            UserInventory.SelectedIndex  = -1;
            SellButton.IsEnabled         = false;
            ItemDescription.Text         = string.Empty;
            ChangeMoneyAmount();
            FillGrids();
        }
Ejemplo n.º 2
0
        private void DisassembleItem(object sender, RoutedEventArgs e)
        {
            var disassemblerWindow = new DisassemblingPopup(ItemTracker);

            disassemblerWindow.ShowDialog();

            if (disassemblerWindow.shouldDisassembleItem)
            {
                DbTransactionHolder.UpdateEquipmentItemQuantity(UserInventoryView, ItemTracker.SelectedItem, ItemTracker.SelectedItem.Quantity - 1);
                ItemTracker.SelectedItem.Quantity -= 1;
                foreach (var product in ItemTracker.SelectedItem.DisassemblyProducts)
                {
                    if (UserInventoryView.FullInventoryView.Find(x => x.ProductId == product.Id && x.Quantity < x.StackLimit) is InventoryViewRow inventoryElement)
                    {
                        inventoryElement.Quantity += 1;
                        DbTransactionHolder.UpdateEquipmentItemQuantity(UserInventoryView, inventoryElement, inventoryElement.Quantity);
                    }
                    else
                    {
                        inventoryElement = new InventoryViewRow(product);
                        UserInventoryView.FullInventoryView.Add(inventoryElement);
                        DbTransactionHolder.AddEquipmentItem(UserInventoryView, inventoryElement, 1);
                    }
                }
            }

            if (ItemTracker.SelectedItem.Quantity <= 0)
            {
                UserInventoryView.FullInventoryView.Remove(ItemTracker.SelectedItem);
                DbTransactionHolder.DeleteEquipmentItem(UserInventoryView, ItemTracker.SelectedItem);
            }
            DisassemblyButton.Visibility = Visibility.Collapsed;
            ConsumeButton.Visibility     = Visibility.Collapsed;
            UserInventory.SelectedIndex  = -1;
            SellButton.IsEnabled         = false;
            ItemDescription.Text         = string.Empty;
            FillGrids();
        }