Example #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();
        }
Example #2
0
        /// <summary>
        /// Request the info of the distributor and prints it.
        /// </summary>
        private void GetInfo()
        {
            string name;

            Console.Clear();

            Console.WriteLine(new string('-', 40));
            Console.WriteLine(new string(' ', 10) + "GET INFORMATION");
            Console.WriteLine(new string('-', 40));
            Console.WriteLine();

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

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

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

            Console.WriteLine(DistributorBusiness.GetInfo(DistributorBusiness.GetID(name)));
            Console.ReadKey();
        }
Example #3
0
        /// <summary>
        /// Request a new distributor to be added.
        /// </summary>
        private void CreateDistributor()
        {
            Console.Write("Name: ");
            string name = Console.ReadLine();

            Console.Write("Address: ");
            string address = Console.ReadLine();

            Console.Write("Email: ");
            string email = Console.ReadLine();

            Console.Write("Phone: ");
            string phone = Console.ReadLine();

            DistributorBusiness.CreateDistributor(name, address, email, phone);
        }
Example #4
0
        /// <summary>
        /// Requests a product to be removed from the distributor.
        /// </summary>
        private void RemoveProduct()
        {
            string distributorName, productName;

            Console.Clear();

            Console.WriteLine(new string('-', 41));
            Console.WriteLine(new string(' ', 15) + "ADD 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');
            }

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

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

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

            DistributorBusiness.RemoveProduct(DistributorBusiness.GetID(distributorName), ProductBusiness.GetID(productName));
        }
Example #5
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);
        }
Example #6
0
        /// <summary>
        /// Request a new product to be added to the distributor.
        /// </summary>
        private void CreateProduct()
        {
            string  productName, distributorName;
            decimal price;

            Console.Clear();

            Console.WriteLine(new string('-', 41));
            Console.WriteLine(new string(' ', 15) + "ADD 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');
            }

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

                if (!ProductBusiness.CheckForProduct(ProductBusiness.GetID(productName)))
                {
                    break;
                }

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

            while (true)
            {
                Console.Write("Price for one product: ");
                price = decimal.Parse(Console.ReadLine());
                Console.WriteLine();

                if (!(price <= 0))
                {
                    break;
                }

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

            ProductBusiness.AddProduct(DistributorBusiness.GetID(distributorName), productName, price);
        }