Esempio n. 1
0
        // Parameter basket is needed when customer already has a basket and wants to insert more products before confirming order
        public static Basket AskForWhichProductsCustomerWantsToBuy(Basket basket = null)
        {
            Console.WriteLine("\nFavor informar quantos produtos distintos gostaria de comprar.");
            var quantityOfDistinctProductsCustomerWantsToBuy = int.Parse(Console.ReadLine());

            // newBasket received param basket if not null
            Basket newBasket = basket ?? new Basket();

            for (int i = 0; i < quantityOfDistinctProductsCustomerWantsToBuy; i++)
            {
                Product product = null;

                // ask for product id until customer sends a valid id
                while (product == null)
                {
                    Console.WriteLine("\nFavor informar o ID do produto numero {0} que deseja comprar: ", i + 1);
                    var productID = int.Parse(Console.ReadLine());
                    product = ProductsRegisterManager.GetProductRegisteredByID(productID);
                }

                Console.WriteLine("\nFavor informar a quantidade do produto {0} que deseja comprar: ", product.Name);
                var quantityOfProductCustomerWantsToBuy = int.Parse(Console.ReadLine());

                // insert item into basket
                newBasket.AddOrUpdateItemToBasket(product, quantityOfProductCustomerWantsToBuy);
            }

            return(newBasket);
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            ProductsRegisterManager.RegisterAllProducts();
            CustomerService.PrintListOfProductsAvailableToSell();
            var basket = CustomerService.AskForWhichProductsCustomerWantsToBuy();

            CustomerService.AskCustomerToCreateOrderOrBuyMore(basket);
        }