internal static void Run()
        {
            Order oldOrder = LookupOrder();

            string   name    = EditCustomerName(oldOrder.CustomerName);
            StateTax tax     = EditState(oldOrder.StateTax);
            Material product = EditProduct(oldOrder.Product);
            decimal  area    = EditArea(oldOrder.Area);

            Order newOrder = new Order(oldOrder, name, tax, product, area);

            Console.Clear();
            ConsoleIO.PrintOrder(newOrder, true);
            bool saveEditedOrder = ConsoleIO.ConsoleKeyConfirmationSwitch("Would you like to replace the old order with this updated order?", true);

            if (saveEditedOrder)
            {
                Console.Clear();
                Manager           manager      = ManagerFactory.Create();
                EditOrderResponse editResponse = manager.EditOrder(newOrder);

                if (editResponse.Success)
                {
                    Console.WriteLine("Order updated successfully.");
                }
                else
                {
                    Console.WriteLine(editResponse.Message);
                }
            }
            Console.Write("Press any key to continue...");
            Console.ReadKey();
        }
예제 #2
0
        internal static void Run()
        {
            Manager manager = ManagerFactory.Create();
            var     date    = GetDate();
            var     name    = GetName();
            var     tax     = GetTax(manager);
            var     product = GetProduct(manager);
            var     area    = GetArea();

            Console.Clear();
            Order order = new Order(date, product, tax, name, area);

            ConsoleIO.TitleHeader("Confirm Order");
            ConsoleIO.PrintOrder(order, false);

            bool confirmOrder = ConsoleIO.ConsoleKeyConfirmationSwitch("", true);

            if (confirmOrder)
            {
                AddOrderResponse addOrderResponse = manager.AddOrder(order);

                if (addOrderResponse.Success)
                {
                    Console.Clear();
                    Console.WriteLine($"Order for {order.CustomerName} for {order.OrderDate.ToString("MM/dd/yyyy")} saved successfully.");
                }
                else
                {
                    Console.Clear();
                    Console.WriteLine(addOrderResponse.Message);
                }
            }
            Console.Write("Press any key to continue.");
            Console.ReadKey();
        }
예제 #3
0
        private static decimal GetArea()
        {
            bool    validArea = false;
            decimal area      = 0;

            while (!validArea)
            {
                Console.Clear();
                ConsoleIO.TitleHeader("Add an Order");
                Console.WriteLine("(Step 5 of 5)\n");
                area      = ConsoleIO.GetAreaFromUser();
                validArea = ConsoleIO.ConsoleKeyConfirmationSwitch($"Desired square footage for the order is {area}. ", false);
            }
            return(area);
        }
        internal static void Run()
        {
            Console.Clear();
            ConsoleIO.TitleHeader("Remove an Order");
            Console.WriteLine();
            DateTime date     = ConsoleIO.GetDateFromUser();
            int      orderNum = ConsoleIO.GetIntFromUser("Please enter an order number: ");

            Manager           manager          = ManagerFactory.Create();
            GetOrdersResponse getOrderResponse = manager.GetOrders(date);
            Order             toRemove;

            try
            {
                toRemove = getOrderResponse.OrdersOnDate.Single(o => o.OrderNumber == orderNum);
            }
            catch
            {
                Console.Clear();
                Console.Write("No order with that date and order number could be found. Press any key to continue... ");
                Console.ReadKey();
                toRemove = null;
            }

            if (toRemove != null)
            {
                Console.Clear();
                ConsoleIO.PrintOrder(toRemove, true);
                bool userConfirmsRemove = ConsoleIO.ConsoleKeyConfirmationSwitch("Would you like to remove this order from the repository?", false);

                if (userConfirmsRemove)
                {
                    RemoveOrderResponse response = manager.RemoveOrder(toRemove);
                    Console.Clear();
                    if (response.Success)
                    {
                        Console.Write($"Successfully removed order #{response.Order.OrderNumber} for {response.Order.CustomerName} on {response.Order.OrderDate.ToString("MM/dd/yyyy")}. Press any key to continue...");
                        Console.ReadKey();
                    }
                    else
                    {
                        Console.Write(response.Message + "\nPress any key to continue...");
                        Console.ReadKey();
                    }
                }
            }
        }
예제 #5
0
        private static Material GetProduct(Manager manager)
        {
            bool     validProduct = false;
            Material product      = null;

            while (!validProduct)
            {
                Console.Clear();
                ConsoleIO.TitleHeader("Add an Order");
                Console.WriteLine("(Step 4 of 5)\n");

                GetProductsResponse getProductResponse = manager.GetProducts();
                if (getProductResponse.Success)
                {
                    ConsoleIO.PrintProducts(getProductResponse.Materials);
                }
                else
                {
                    Console.WriteLine(getProductResponse.Message);
                    Console.Write("Press any key to continue...");
                    Console.ReadKey();
                }

                string userProductInput = ConsoleIO.GetProductFromUser();

                CheckProductResponse checkProdResponse = manager.CheckForRequestedProduct(userProductInput);

                if (checkProdResponse.Success == true)
                {
                    validProduct = true;
                    product      = checkProdResponse.Product;
                }
                else
                {
                    Console.Clear();
                    Console.WriteLine(checkProdResponse.Message);
                    Console.Write("Press any key to retry...");
                    Console.ReadKey();
                }
                if (validProduct)
                {
                    validProduct = ConsoleIO.ConsoleKeyConfirmationSwitch($"Entered product is ({userProductInput}).", false);
                }
            }
            return(product);
        }