Ejemplo n.º 1
0
        public void Execute()
        {
            _outputReciever.ClearScreen();
            _outputReciever.WriteLine("Select product:\n");

            _listManager.SetItems(_cartService.GetCartItems());
            _listManager.SetItemToString(item => $"{item.Product.Name}");
            _listManager.PrintItems();

            _outputReciever.Write("Your choise: ");
            var selectedItem = _listManager.GetSelectedItem();

            if (selectedItem.IsNull())
            {
                _outputReciever.WriteError("You didn't select anything. Try again.");
                return;
            }

            _outputReciever.Write("\nHow much products do we need to add to cart? [1] ");
            var count = _outputReciever.GetIntResponse() ?? 1;

            if (count < 1)
            {
                _outputReciever.WriteError("Can't add less than 1 product.");
                return;
            }

            _cartService.AddProduct(selectedItem.Product, Convert.ToUInt32(count));

            _outputReciever.WriteInfo($"Added {count} product(-s).");
        }
Ejemplo n.º 2
0
        public void Execute()
        {
            _outputReciever.ClearScreen();
            _outputReciever.Write("How much commands do we need to do again? [1] ");
            var count = _outputReciever.GetIntResponse() ?? 1;

            _cartService.Redo(Convert.ToUInt32(count));
            _outputReciever.WriteInfo($"Up to {count} command(-s) was successfully redone.");
        }
Ejemplo n.º 3
0
        public T GetSelectedItem()
        {
            var prod = _outputReciever.GetIntResponse() ?? -1;

            if (prod >= 0 && prod <= _items.Count - 1)
            {
                return(_items[prod]);
            }

            return(null);
        }