Пример #1
0
        /// <summary>
        /// Select product method. Contains catches for not in inventory, sold out, insufficient stock, and insufficent funds.
        /// </summary>
        /// <param name="userInput"></param>
        private void SelectProduct(string userInput)
        {
            if (catering.SearchProductCode(userInput) == null)
            {
                Console.WriteLine("Sorry, the product you requested is not in our inventory. Please try again.");
            }
            else if (catering.ProductIsInStock(userInput) == null)
            {
                Console.WriteLine("Sorry, the product you requested is sold out. Please try again.");
            }
            else if (catering.ProductIsInStock(userInput) != null)
            {
                Console.WriteLine("How many do you want to purchase?");
                int userQuantityWanted = int.Parse(Console.ReadLine());

                if (catering.ProductIsInStock(userInput).QuantityInStock < userQuantityWanted)
                {
                    Console.WriteLine("Sorry, we have insufficient stock of that item.");
                }
                else if (catering.ProductIsInStock(userInput).Price *userQuantityWanted > accounting.DisplayMoney())
                {
                    Console.WriteLine("We're sorry, but you have insufficient funds to complete this transaction.");
                }
                else
                {
                    CateringItem itemPurchased = catering.SearchProductCode(userInput);
                    accounting.SubtractPurchase(catering, itemPurchased, userQuantityWanted);
                    files.PurchasesLog(itemPurchased, accounting, userQuantityWanted);
                }
            }
        }