Ejemplo n.º 1
0
        private void ChooseProduct(IStorage myStorage)
        {
            Console.WriteLine("Please,type number of product You want to buy:");
            int choice = InputUtility.GetInputFromUser();
            var supplierProductList = myStorage.GetItemsThatCanBePurshed();

            if (choice < 0 || choice > supplierProductList.Count())
            {
                Console.WriteLine("There's no item with such number, try again");
                return;
            }

            var rand  = new Random();
            var piece = new Glassware
            {
                Name      = supplierProductList[choice].Name,
                Volume    = supplierProductList[choice].Volume,
                Price     = supplierProductList[choice].Price,
                Id        = Guid.NewGuid(),
                Condition = "New",
                Quality   = 100,
                IsClean   = true
            };

            myStorage.AddItem(piece);
            Console.WriteLine($"Item {piece.Name} was added!");
        }
Ejemplo n.º 2
0
        private void MoveNormal(Player player, byte fromSlot, byte toSlot, Storages toStorage, IStorage fromItemStorage, Item item, IStorage toItemStorage)
        {
            fromItemStorage.RemoveItem(item);
            if (!toItemStorage.AddItem(toSlot, item))
            {
                fromItemStorage.AddItem(item);

                player.ViewPlugIns.GetPlugIn <IItemMoveFailedPlugIn>()?.ItemMoveFailed(item);
                return;
            }

            player.ViewPlugIns.GetPlugIn <Views.Inventory.IItemMovedPlugIn>()?.ItemMoved(item, toSlot, toStorage);
            var isTradeOngoing = player.PlayerState.CurrentState == PlayerState.TradeOpened ||
                                 player.PlayerState.CurrentState == PlayerState.TradeButtonPressed;
            var isItemMovedToOrFromTrade = toItemStorage == player.TemporaryStorage || fromItemStorage == player.TemporaryStorage;

            if (isTradeOngoing && isItemMovedToOrFromTrade && player.TradingPartner is Player tradingPartner)
            {
                // When Trading, send update to Trading-Partner
                if (fromItemStorage == player.TemporaryStorage)
                {
                    tradingPartner.ViewPlugIns.GetPlugIn <ITradeItemDisappearPlugIn>()?.TradeItemDisappear(fromSlot, item);
                }

                if (toItemStorage == player.TemporaryStorage)
                {
                    tradingPartner.ViewPlugIns.GetPlugIn <ITradeItemAppearPlugIn>()?.TradeItemAppear(toSlot, item);
                }
            }
        }
Ejemplo n.º 3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            var      processor = new Processor(tbName.Text, int.Parse(tbPrice.Text), tbCompany.Text, int.Parse(tbAmount.Text), int.Parse(tbCoresNum.Text), double.Parse(tbFrequency.Text), int.Parse(tbProcessTechnology.Text), int.Parse(tbCacheSize.Text), int.Parse(tbThermalDesignPower.Text));
            IStorage storage   = ListItemStorage.GetInstance();

            storage.AddItem(processor);
            this.Close();
        }
Ejemplo n.º 4
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            var      powerSupply = new PowerSupply(tbName.Text, int.Parse(tbPrice.Text), tbCompany.Text, int.Parse(tbAmount.Text), int.Parse(tbEfficiency.Text), int.Parse(tbPower.Text));
            IStorage storage     = ListItemStorage.GetInstance();

            storage.AddItem(powerSupply);
            this.Close();
        }
Ejemplo n.º 5
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            var      systemCase = new SystemCase(tbName.Text, int.Parse(tbPrice.Text), tbCompany.Text, int.Parse(tbAmount.Text), int.Parse(tbFansAmount.Text), int.Parse(tbUSBPorts.Text));
            IStorage storage    = ListItemStorage.GetInstance();

            storage.AddItem(systemCase);
            this.Close();
        }
Ejemplo n.º 6
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            var      memory  = new RAM(tbName.Text, int.Parse(tbPrice.Text), tbCompany.Text, int.Parse(tbAmount.Text), int.Parse(tbFrequency.Text), int.Parse(tbCapacity.Text), tbType.Text);
            IStorage storage = ListItemStorage.GetInstance();

            storage.AddItem(memory);
            this.Close();
        }
Ejemplo n.º 7
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            var      hardDrive = new HardDrive(tbName.Text, int.Parse(tbPrice.Text), tbCompany.Text, int.Parse(tbAmount.Text), int.Parse(tbCapacity.Text), int.Parse(tbRotateSpeed.Text), tbConnectionInterface.Text);
            IStorage storage   = ListItemStorage.GetInstance();

            storage.AddItem(hardDrive);
            this.Close();
        }
Ejemplo n.º 8
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            var      motherboard = new Motherboard(tbName.Text, int.Parse(tbPrice.Text), tbCompanyName.Text, int.Parse(tbAmount.Text), tbCPUSupport.Text, tbSocket.Text, tbFormFactor.Text);
            IStorage storage     = ListItemStorage.GetInstance();

            storage.AddItem(motherboard);
            this.Close();
        }
        public bool ConsumeAddInstanceSubscription(AddInstanceSubscription subscription)
        {
            if (logger.IsDebugEnabled)
            {
                logger.DebugFormat("Adding instance subscription for {0} on {1}.", subscription.InstanceSubscriptionKey, subscription.Endpoint);
            }

            int itemId = storage.AddItem(SubscriptionsKey + localEndpoint, subscription, SerializeMessage);

            remoteInstanceSubscriptions.Add(
                subscription.InstanceSubscriptionKey,
                subscription.Type,
                new Uri(subscription.Endpoint),
                itemId);

            RaiseSubscriptionChanged();
            return(true);
        }
Ejemplo n.º 10
0
        private void PutItemInStorage()
        {
            _playerInventory.RemoveItem(_selectedItem.ItemReference);
            _openedStorage.AddItem(_selectedItem.ItemReference);

            _itemManageWindow.Hide();

            ShowPlayerInventoryItems();
            ShowOpenedStorageItems();
        }
Ejemplo n.º 11
0
 /// <summary>
 /// Add item to Storage
 /// </summary>
 /// <param name="key">
 /// If the type of storage is sqlite,
 /// should be the format of "Type/TypeID"
 /// Eg:If you have a type of "Person" and the id is 123
 /// so the format will like "Person/123"
 /// </param>
 /// <param name="value"></param>
 /// <returns></returns>
 public void AddItem(string key, object value)
 {
     storage.AddItem(key, value);
 }