コード例 #1
0
        /// <summary>
        /// Requests a check for if a product exists and prints a message depending on the outcome.
        /// </summary>
        private void CheckProduct()
        {
            string distributorName, productName;

            Console.Clear();

            Console.WriteLine(new string('-', 41));
            Console.WriteLine(new string(' ', 12) + "CHECK FOR PRODUCT");
            Console.WriteLine(new string('-', 41) + '\n');

            while (true)
            {
                Console.Write("Distributor name: ");
                distributorName = Console.ReadLine();
                Console.WriteLine();

                if (DistributorBusiness.DistributorExists(DistributorBusiness.GetID(distributorName)))
                {
                    break;
                }

                Console.WriteLine(new string('-', 26));
                Console.WriteLine("Please enter a valid distributor name!");
                Console.WriteLine(new string('-', 26) + '\n');
            }

            Console.Write("Product name: ");
            productName = Console.ReadLine();
            Console.WriteLine();

            Console.WriteLine(DistributorBusiness.CheckForProduct(DistributorBusiness.GetID(distributorName), ProductBusiness.GetID(productName)) ? $"Distributor {distributorName} provides product: {productName}" : $"Distributor {distributorName} does not provide product: {productName}");
            Console.ReadKey();
        }
コード例 #2
0
        /// <summary>
        /// Request a product to be loaded to an office.
        /// </summary>
        private void LoadProduct()
        {
            string officeName, distributorName, productName;
            int    stock;

            Console.Clear();

            Console.WriteLine(new string('-', 40));
            Console.WriteLine(new string(' ', 14) + "LOAD PRODUCT");
            Console.WriteLine(new string('-', 40) + '\n');

            while (true)
            {
                Console.Write("Office name: ");
                officeName = Console.ReadLine();
                Console.WriteLine();

                if (OfficeBusiness.OfficeExists(officeName))
                {
                    break;
                }

                Console.WriteLine(new string('-', 26));
                Console.WriteLine("Please enter a valid office name!");
                Console.WriteLine(new string('-', 26) + '\n');
            }

            while (true)
            {
                Console.Write("Distributor name: ");
                distributorName = Console.ReadLine();
                Console.WriteLine();

                if (!(distributorName.Length < 1) && DistributorBusiness.DistributorExists(DistributorBusiness.GetID(distributorName)))
                {
                    break;
                }

                Console.WriteLine(new string('-', 26));
                Console.WriteLine("Please enter a valid name!");
                Console.WriteLine(new string('-', 26) + '\n');
            }

            while (true)
            {
                Console.Write("Product name: ");
                productName = Console.ReadLine();
                Console.WriteLine();

                if (DistributorBusiness.CheckForProduct(DistributorBusiness.GetID(distributorName), ProductBusiness.GetID(productName)))
                {
                    break;
                }

                Console.WriteLine(new string('-', 27));
                Console.WriteLine("Please enter a valid price!");
                Console.WriteLine(new string('-', 27) + '\n');
            }

            while (true)
            {
                Console.Write("Stock: ");
                stock = int.Parse(Console.ReadLine());
                Console.WriteLine();

                if (!(stock < 0))
                {
                    break;
                }

                Console.WriteLine(new string('-', 27));
                Console.WriteLine("Please enter a valid stock!");
                Console.WriteLine(new string('-', 27) + '\n');
            }

            OfficeBusiness.LoadProduct(OfficeBusiness.GetID(officeName), DistributorBusiness.GetProduct(DistributorBusiness.GetID(distributorName), ProductBusiness.GetID(productName)), stock);
        }