示例#1
0
        public void StockUp(string nameString, string priceString, string amountString)
        {
            string name       = nameString.Trim().ToLower();
            int    price      = _inputValidation.ConvertPrice(priceString);
            int    amount     = _inputValidation.ConvertAmount(amountString);
            string stockUpMsg = "";

            for (int i = 0; i < amount; i++)
            {
                ProductsList.Add(new Products()
                {
                    ProductName = name,
                    Price       = price
                });
            }
            if (amount == 1)
            {
                stockUpMsg += $"{amount} {name} was added to the shop with the price of {price} $";
            }
            else
            {
                stockUpMsg += $"{amount} {name} products ware added to the shop with the price of {price} $";
            }
            _service.WriteResult(stockUpMsg);
        }