Exemplo n.º 1
0
        public void Execute()
        {
            string workflow = "Display";

            OrderManager manager = OrderManagerFactory.Create();

            Headers.DisplayHeader(workflow);

            //date verification should happen at the order manager or repository level
            DateTime date = ConsoleIO.GetExistingOrderDate("Enter a date to display orders (MM/DD/YYYY):");

            OrderGetListResponse response = manager.GetOrderList(date);

            Headers.DisplayHeader(workflow);

            if (response.Success)
            {
                foreach (var ord in response.Orders)
                {
                    ShowDetails.DisplayOrderDetails(ord);
                }
            }
            else
            {
                Console.WriteLine("An error occured: ");
                Console.WriteLine(response.Message);
            }

            Console.WriteLine("Press any key to continue...");
            Console.ReadKey();
        }
Exemplo n.º 2
0
        public void Execute()
        {
            string workflow = "Remove";

            OrderManager orderManager = OrderManagerFactory.Create();

            Headers.DisplayHeader(workflow);

            //get date
            DateTime date = ConsoleIO.GetExistingOrderDate("Enter the date of the order you would like to remove (MM/DD/YYYY): ");

            Headers.DisplayHeader(workflow);

            //get order number
            int orderNumber = ConsoleIO.GetOrderNumberFromUser("Enter the order number: ");

            OrderGetSingleResponse getOrderResponse = orderManager.GetSingleOrder(date, orderNumber);

            if (getOrderResponse.Success)
            {
                Headers.DisplayHeader(workflow);
                ShowDetails.DisplayOrderDetails(getOrderResponse.Order);

                if (ConsoleIO.GetYesOrNo("Would you like to remove this order?") == "Y")
                {
                    OrderRemoveResponse removeOrderResponse = orderManager.RemoveOrder(getOrderResponse.Order);
                    if (!removeOrderResponse.Success)
                    {
                        Console.WriteLine("There was an error removing the order.");
                        Console.WriteLine(removeOrderResponse.Message);
                    }
                    else
                    {
                        Console.WriteLine("Order removed! Press any key to return to main menu...");
                        Console.ReadKey();
                    }
                }
                else
                {
                    Console.WriteLine("Remove cancelled. Press any key to return to Main Menu...");
                    Console.ReadKey();
                }
            }
            else
            {
                Console.WriteLine("An error occured:");
                Console.WriteLine(getOrderResponse.Message);
                Console.WriteLine("Press any key to return to main menu...");
                Console.ReadKey();
                return;
            }
        }
Exemplo n.º 3
0
        public void Execute()
        {
            string workflow = "Add";

            OrderManager orderManager = OrderManagerFactory.Create();

            Headers.DisplayHeader(workflow);

            //create order object
            Order newOrder = new Order();

            //get date
            newOrder.Date = ConsoleIO.GetNewOrderDate("Enter a date (MM/DD/YYYY):");

            //get order number
            newOrder.OrderNumber = OrderNumberValidation.CreateOrderNumber(newOrder.Date);

            Headers.DisplayHeader(workflow);

            //get customer name
            newOrder.CustomerName = ConsoleIO.GetCustomerName("Add", "none");

            Headers.DisplayHeader(workflow);

            //get state tax
            bool     validState = false;
            StateTax stateTax   = null;

            while (!validState)
            {
                string   stateAbbratiavtion = ConsoleIO.GetStateInputFromUser("Add");
                StateTax tempStateTax       = StateTaxValidation.CreateStateTax(stateAbbratiavtion).State;
                if (tempStateTax == null)
                {
                    validState = false;
                }
                else
                {
                    stateTax   = tempStateTax;
                    validState = true;
                }
            }

            Headers.DisplayHeader(workflow);

            //set state
            newOrder.State   = stateTax.StateAbbreviation;
            newOrder.TaxRate = stateTax.TaxRate;

            //get product
            List <Product> products = ProductListValidation.CreateProductList();
            Product        product  = ConsoleIO.DisplayProducts(products, "Add");

            newOrder.ProductType            = product.ProductType;
            newOrder.CostPerSquareFoot      = product.CostPerSquareFoot;
            newOrder.LaborCostPerSquareFoot = product.LaborCostPerSquareFoot;

            Headers.DisplayHeader(workflow);

            //get area
            newOrder.Area = ConsoleIO.GetArea("Add");

            Headers.DisplayHeader(workflow);

            //display new order
            ShowDetails.DisplayOrderDetails(newOrder);

            //--show message if add failed--
            if (ConsoleIO.GetYesOrNo("Add order? ") == "Y")
            {
                OrderAddResponse response = orderManager.AddOrder(newOrder);
                if (!response.Success)
                {
                    Console.WriteLine("There was an error adding the order:");
                    Console.WriteLine(response.Message);
                }
                else
                {
                    Console.WriteLine("Order added! Press any key to continue...");
                    Console.ReadKey();
                }
            }
            else
            {
                Console.WriteLine("Order cancelled :(");
                Console.ReadLine();
            }
        }
Exemplo n.º 4
0
        public void Execute()
        {
            string workflow = "Edit";

            OrderManager    orderManager    = OrderManagerFactory.Create();
            StateTaxManager stateTaxManager = StateTaxManagerFactory.Create();
            ProductManager  productManager  = ProductManagerFactory.Create();

            Headers.DisplayHeader(workflow);

            //get date
            DateTime date = ConsoleIO.GetExistingOrderDate("Enter the date of the order you would like to edit (MM/DD/YYYY): ");

            Headers.DisplayHeader(workflow);

            //get order number
            int orderNumber = ConsoleIO.GetOrderNumberFromUser("Enter the order number: ");

            OrderGetSingleResponse orderResponse = orderManager.GetSingleOrder(date, orderNumber);

            if (orderResponse.Success)
            {
                Headers.DisplayHeader(workflow);
                ShowDetails.DisplayOrderDetails(orderResponse.Order);
                Console.WriteLine("Press any key to begin editing...");
                Console.ReadKey();
            }
            else
            {
                Console.WriteLine("An error occured:");
                Console.WriteLine(orderResponse.Message);
                Console.WriteLine("Press any key to return to main menu...");
                Console.ReadKey();
                return;
            }

            Headers.DisplayHeader(workflow);


            //edit name
            string editName = ConsoleIO.GetCustomerName("Edit", orderResponse.Order.CustomerName);

            Headers.DisplayHeader(workflow);

            //edit state
            bool     validInput   = false;
            StateTax editStateTax = null;

            while (!validInput)
            {
                string editState = ConsoleIO.GetStateInputFromUser("Edit");
                if (editState == "")
                {
                    validInput = true;
                }
                else
                {
                    StateTaxResponse stateTaxResponse = stateTaxManager.GetStateTax(editState);
                    if (stateTaxResponse.Success == true)
                    {
                        editStateTax = stateTaxResponse.State;
                        validInput   = true;
                    }
                }
            }

            Headers.DisplayHeader(workflow);


            //edit product type
            List <Product> products    = productManager.GetProductList().Products;
            Product        editProduct = ConsoleIO.DisplayProducts(products, "Edit");

            Headers.DisplayHeader(workflow);

            //edit area

            decimal editArea = ConsoleIO.GetArea("Edit");

            Headers.DisplayHeader(workflow);

            //display order changes

            Order editOrder = new Order(orderResponse.Order);

            if (editName != "")
            {
                editOrder.CustomerName = editName;
            }
            if (editStateTax != null)
            {
                editOrder.State   = editStateTax.StateAbbreviation;
                editOrder.TaxRate = editStateTax.TaxRate;
            }
            if (editProduct != null)
            {
                editOrder.ProductType            = editProduct.ProductType;
                editOrder.LaborCostPerSquareFoot = editProduct.LaborCostPerSquareFoot;
                editOrder.CostPerSquareFoot      = editProduct.CostPerSquareFoot;
            }
            if (editArea != int.MaxValue)
            {
                editOrder.Area = editArea;
            }

            //send it!
            ShowDetails.DisplayOrderDetails(editOrder);

            if (ConsoleIO.GetYesOrNo("Submit changes to order?") == "Y")
            {
                OrderAddEditedResponse response = orderManager.AddEditedOrder(editOrder);
                if (!response.Success)
                {
                    Console.WriteLine("There was an error adding the order:");
                    Console.WriteLine(response.Message);
                }
                else
                {
                    Console.WriteLine("Order added! Press any key to return to main menu...");
                    Console.ReadKey();
                }
            }
            else
            {
                Console.WriteLine("Edit order cancelled :( Press any key to continue...");
                Console.ReadKey();
            }
        }