예제 #1
0
        public void OrderToConfirm(Order orderToAdd)
        {
            var orderOps = new OrderOperations();
            DateTime orderDateToday = DateTime.Today;
            var confirmOrder = "";
            bool validEntry = true;

            do
            {
                Console.WriteLine("Would you like to place this order? Please enter Yes or No.");
                confirmOrder = Console.ReadLine();
                confirmOrder = confirmOrder.Substring(0, 1).ToUpper();
                if (confirmOrder != "Y" && confirmOrder != "N")
                {
                    Console.WriteLine("That is an invalid entry. Please input yes or no.");
                    validEntry = false;
                }
                if (string.IsNullOrEmpty(confirmOrder))
                {
                    Console.WriteLine("You must make a selection. Please input Yes or No.");
                    validEntry = false;
                }
                else
                {
                    validEntry = true;
                }
            } while (!validEntry);

            if (confirmOrder == "Y")
            {
                orderOps.NewOrderNumber(orderToAdd, orderDateToday);
                var response = orderOps.AddNewOrder(orderToAdd, orderDateToday);

                if (response.Success)
                {
                    Console.WriteLine("========| Order Confirmation | ========");
                    Console.WriteLine("Order number: {0}",response.Data.OrderNumber);
                    Console.WriteLine("Product Type: {0}", response.Data.ProductType);
                    Console.WriteLine("Amount Ordered: {0}sqft", response.Data.Area);
                    Console.WriteLine("Material Cost: {0:c}", response.Data.MaterialCost);
                    Console.WriteLine("Labor Cost: {0:c}", response.Data.LaborCost);
                    Console.WriteLine("Tax: {0:c}", response.Data.Tax);
                    Console.WriteLine("Total: {0:c}", response.Data.Total);
                }
            }
            else
            {
                var response = orderOps.AddNewOrder(orderToAdd, orderDateToday);
                Console.WriteLine(response.Message);
            }
        }