예제 #1
0
        public bool CheckProduct(string productType)
        {
            var prod = new FileData.ProductRepo();

            var products = prod.DisplayAll();

            string productChoice = productType;

            foreach (var p in products)
            {
                if (productChoice == p.ProductType)
                {
                    return(true);
                }
            }
            return(false);
        }
예제 #2
0
        // Validation I believe is complete. Hopefully done.
        public void AddOrder()
        {
            //this will have a service method that will be adding both both the product and taxes together, as well as user input.

            var prod = new FileData.ProductRepo();

            var    products      = prod.DisplayAll();
            var    tax           = new FileData.TaxRepo();
            var    taxes         = tax.DisplayAll();
            bool   complete      = false;
            string productChoice = "";
            string taxChoice     = "";
            string length        = "";
            string width         = "";


            string name = ReadString("Please Enter In Your Name: ");

            foreach (var p in products)
            {
                Console.WriteLine($"{p.ProductType}\t{p.CostSqFeet}\t{p.LaborCost}");
            }

            while (complete == false)
            {
                productChoice = ReadString("Please Enter In the Product You Wish To Use: ");
                {
                    var result = service.CheckProduct(productChoice);
                    if (result == false)
                    {
                        Console.WriteLine("Please enter in a valid product.");
                    }
                    else if (result == true)
                    {
                        break;
                    }
                }
            }
            while (complete == false)
            {
                taxChoice = ReadString("Please Enter In What State You Live In: ");
                var result = service.CheckTaxes(taxChoice);
                {
                    if (result == false)
                    {
                        Console.WriteLine("Please enter in a valid State!");
                    }
                    else if (result == true)
                    {
                        break;
                    }
                }
            }
            while (complete != true)
            {
                length = ReadString("What Is The Length of the room (FT): ");
                width  = ReadString("What Is The Width Of The Room (FT): ");

                var result = service.CheckNumbers(length, width);
                if (result == false)
                {
                    Console.WriteLine("Please enter in a number.");
                }
                else if (result == true)
                {
                    break;
                }
            }
            while (complete == false)
            {
                string date = ReadString("Please Enter In The Date You Would Like The Order To Be Filled: ");
                DateTime.TryParse(date, out DateTime dt);


                if (dt == null)
                {
                    Console.WriteLine("Please enter in a valid input");
                }
                else
                {
                    if (DateTime.Now > dt)
                    {
                        Console.WriteLine("Please enter in a valid date in the FUTURE");
                    }
                    else
                    {
                        var order = service.CreateOrder(productChoice, taxChoice, dt, name, length, width);
                        break;
                    }
                }
            }
        }