public void Execute()
        {
            OrderManager manager = OrderManagerFactory.Create();

            DateTime orderDate;

            Console.Clear();
            Console.WriteLine("Lookup an Order");
            Console.WriteLine("----------------------");
            Console.Write("Enter the Order Date:  ");
            while (!DateTime.TryParse(Console.ReadLine(), out orderDate))
            {
                Console.WriteLine("That is not a valid format, please try again");
            }

            OrderLookupResponse response = manager.AllOrderLookup(orderDate);

            if (response.Success)
            {
                foreach (Order order in response.Orders)
                {
                    ConsoleIO.DisplayOrder(order);
                }
            }
            else
            {
                Console.WriteLine("An error has occured: ");
                Console.WriteLine(response.Message);
            }

            Console.WriteLine("Press any key to continue...");
            Console.ReadKey();
            return;
        }
        public void CanDelete(string OrderDate, string NameInput, string StateInput, string ProductInput, decimal AreaInput, bool success)
        {
            OrderManager manager   = OrderManagerFactory.Create();
            DateTime     orderDate = DateTime.Parse(OrderDate);

            PlaceNewOrderResponse response          = manager.NewOrder(orderDate, NameInput, StateInput, ProductInput, AreaInput);
            AllOrdersResponse     preDeleteResponse = manager.AllOrderLookup(orderDate);
            int placedCount = preDeleteResponse.ListOfOrders.Count;

            DeleteOrderResponse responseDelete     = manager.DeleteOrder(response.Order);
            AllOrdersResponse   postDeleteResponse = manager.AllOrderLookup(orderDate);
            int deleteCount = postDeleteResponse.ListOfOrders.Count;

            Assert.AreEqual(success, responseDelete.Success);
            Assert.AreEqual(deleteCount, (placedCount - 1));
        }
Beispiel #3
0
        public void LocateOrderFile()
        {
            DateTime            orderDate = new DateTime(2013, 06, 01);
            OrderLookupResponse response  = manager.AllOrderLookup(orderDate);

            Assert.IsNotNull(response.Orders);
            Assert.IsTrue(response.Success);
        }
Beispiel #4
0
        public void Execute()
        {
            OrderManager manager = OrderManagerFactory.Create();

            Console.Clear();
            Console.WriteLine("Load all orders on a given day");
            Console.WriteLine("-------------------------------");

            DateTime inputOrderDate = new DateTime();
            bool     dateVerify     = false;

            do
            {
                Console.WriteLine("Enter the order date in the format MM/DD/YYYY");
                string stringDate = Console.ReadLine();

                try
                {
                    inputOrderDate = DateTime.Parse(stringDate);
                    dateVerify     = true;
                }
                catch
                {
                    Console.WriteLine("Incorrect format");
                    Console.ReadKey();
                    Console.Clear();
                }
            } while (!dateVerify);

            AllOrdersResponse response = manager.AllOrderLookup(inputOrderDate);

            if (response.Success)
            {
                foreach (Order order in response.ListOfOrders)
                {
                    ConsoleIO.DisplayOrderDetails(order);
                    Console.WriteLine("Press any key to continue to next order...");
                    Console.ReadKey();
                }
            }
            else
            {
                Console.WriteLine("An error occurred");
                Console.WriteLine(response.Message);
            }

            Console.WriteLine("\nPress any key to continue");
            Console.ReadKey();
        }
        public void Execute()
        {
            OrderManager manager = OrderManagerFactory.Create();
            Order        order   = new Order();
            DateTime     orderDate;

            Console.Clear();
            Console.WriteLine("Add an Order");
            Console.WriteLine("--------------------");
            Console.WriteLine("Please enter the Order Date you would like to add");
            while (!DateTime.TryParse(Console.ReadLine(), out orderDate))
            {
                Console.WriteLine("That is not a valid format, please try again");
            }

            OrderLookupResponse fileResponse = manager.AllOrderLookup(orderDate);

            if (fileResponse.Success)
            {
                foreach (Order entry in fileResponse.Orders)
                {
                    ConsoleIO.DisplayOrder(entry);
                }

                Console.Write("Enter the Order Number of the order you wish to delete: ");
                int orderNumberInput;
                while (!int.TryParse(Console.ReadLine(), out orderNumberInput))
                {
                    Console.WriteLine("That is not a valid input.  Try again");
                }
                OrderLookupResponse response = manager.OrderLookup(orderDate, orderNumberInput);
                order = response.Order;

                if (response.Success)
                {
                    string answer = null;
                    while (answer == null)
                    {
                        Console.WriteLine("Are you sure you wish to Delete this Order? (Y/N)");
                        answer = Console.ReadLine().ToUpper();
                        switch (answer)
                        {
                        case "Y":
                            manager.DeleteOrder(order);
                            Console.WriteLine("Order Deleted");
                            Console.WriteLine("Press any key to continue...");
                            Console.ReadKey();
                            break;

                        case "N":
                            Console.WriteLine("Order Not Deleted");
                            Console.WriteLine("Press any key to continue...");
                            Console.ReadKey();
                            break;

                        default:
                            Console.WriteLine("That is not a valid input, try again");
                            answer = null;
                            break;
                        }
                    }
                }
                else
                {
                    Console.WriteLine(response.Message);
                    Console.WriteLine("Press any key to continue...");
                    Console.ReadKey();
                    return;
                }
            }
            else
            {
                Console.WriteLine(fileResponse.Message);
                Console.WriteLine("Press any key to continue...");
                Console.ReadKey();
                return;
            }
        }
        public void Execute()
        {
            OrderManager    manager        = OrderManagerFactory.Create();
            TaxStateManager stateManager   = TaxStateManagerFactory.Create();
            ProductManager  productManager = ProductManagerFactory.Create();
            InputRules      inputManager   = new InputRules();
            Order           order          = new Order();

            DateTime orderDate = DateTime.MinValue;

            Console.Clear();
            Console.WriteLine("Add an Order");
            Console.WriteLine("--------------------");


            //GET ORDER DATE
            OrderLookupResponse response     = new OrderLookupResponse();
            DateCheckResponse   dateResponse = new DateCheckResponse();

            dateResponse.Success = false;
            int orderNumber = 1;

            while (!dateResponse.Success)
            {
                Console.WriteLine("Please enter the Order Date you would like to add:");

                while (!DateTime.TryParse(Console.ReadLine(), out orderDate))
                {
                    Console.WriteLine("That is not a valid format, please try again");
                }
                dateResponse = inputManager.DateCheck(orderDate);
                Console.WriteLine(dateResponse.Message);
            }

            response = manager.AllOrderLookup(orderDate);

            if (response.Success)
            {
                foreach (Order entry in response.Orders)
                {
                    ConsoleIO.DisplayOrder(entry);
                }
                Console.WriteLine();
                Console.WriteLine("Here is the current status of this Order Date");
                if (response.Orders != null)
                {
                    orderNumber = response.Orders.LastOrDefault().OrderNumber + 1;
                }
            }


            //GET CUSTOMER NAME
            string            nameInput    = null;
            NameCheckResponse nameResponse = new NameCheckResponse();

            nameResponse.Success = false;

            while (!nameResponse.Success)
            {
                Console.Write("Enter the Customer's Name:  ");
                nameInput    = Console.ReadLine().Replace(',', '|').Trim();
                nameResponse = inputManager.NameCheck(nameInput);
                Console.WriteLine(nameResponse.Message);
            }
            Console.Clear();


            //GET STATE
            string stateInput = null;

            Console.WriteLine("These are the states in our system, please enter which state.");
            foreach (TaxState state in stateManager.GetTaxStates())
            {
                Console.WriteLine(state.StateName + ", " + state.StateCode);
            }

            TaxStateLookupResponse  stateResponse      = new TaxStateLookupResponse();
            StateInputCheckResponse stateInputResponse = new StateInputCheckResponse();

            stateResponse.Success      = false;
            stateInputResponse.Success = false;

            while (!stateResponse.Success)
            {
                while (!stateInputResponse.Success)
                {
                    Console.Write("Enter the State:  ");
                    stateInput         = Console.ReadLine();
                    stateInputResponse = inputManager.StateCheck(stateInput);
                    Console.WriteLine(stateInputResponse.Message);
                }

                stateResponse = stateManager.FindTaxState(stateInput);
                if (!stateResponse.Success)
                {
                    Console.WriteLine(stateResponse.Message);
                    Console.Write("Enter the State:  ");
                    stateInput = Console.ReadLine();
                }
            }
            Console.Clear();


            //GET PRODUCT MATERIAL
            string productInput = null;

            Console.WriteLine("These are the materials availbale to choose from:");
            foreach (Product product in productManager.GetProducts())
            {
                Console.WriteLine(string.Format("{0},  Labor Cost: {1},  Material Cost: {2}",
                                                product.ProductType,
                                                product.LaborCostPerSquareFoot,
                                                product.CostPerSquareFoot));
            }
            ProductLookupResposnse    productResponse      = new ProductLookupResposnse();
            ProductInputCheckResponse productInputResponse = new ProductInputCheckResponse();

            productResponse.Success      = false;
            productInputResponse.Success = false;

            while (!productResponse.Success)
            {
                while (!productInputResponse.Success)
                {
                    Console.Write("Enter the Type of materials:  ");
                    productInput         = Console.ReadLine();
                    productInputResponse = inputManager.ProductCheck(productInput);
                    Console.WriteLine(productInputResponse.Message);
                }

                productResponse = productManager.FindProduct(productInput);
                if (!productResponse.Success)
                {
                    Console.WriteLine(productResponse.Message);
                    Console.Write("Enter the Type of materials:  ");
                    productInput = Console.ReadLine();
                }
            }
            Console.Clear();


            //GET AREA
            decimal           areaInput    = 0;
            AreaCheckResponse areaResponse = new AreaCheckResponse();

            areaResponse.Success = false;
            while (!areaResponse.Success)
            {
                Console.Write("Enter the square footage of the Area:  ");
                while (!decimal.TryParse(Console.ReadLine(), out areaInput))
                {
                    Console.WriteLine("That is not a valid input.");
                }
                areaResponse = inputManager.AreaCheck(areaInput);
                Console.WriteLine(areaResponse.Message);
            }
            Console.WriteLine("Press any key to continue...");
            Console.ReadKey();


            order = OrderCreation.CreateOrder(orderDate, orderNumber, nameInput, stateInput, productInput, areaInput);
            Console.Clear();
            ConsoleIO.DisplayOrder(order);
            Console.WriteLine();
            string answer = null;

            while (answer == null)
            {
                Console.WriteLine("Do you want to save this order? (Y/N)");
                answer = Console.ReadLine().ToUpper();
                switch (answer)
                {
                case "Y":
                    manager.CreateOrder(order);
                    Console.WriteLine("Order Saved");
                    break;

                case "N":
                    Console.WriteLine("Order Not Saved");
                    break;

                default:
                    Console.WriteLine("That is not a valid input, try again");
                    answer = null;
                    break;
                }
            }
            Console.WriteLine("Press any key to continue...");
            Console.ReadKey();
            return;
        }
Beispiel #7
0
        public void Execute()
        {
            InputRules      inputManager   = new InputRules();
            OrderManager    manager        = OrderManagerFactory.Create();
            TaxStateManager stateManager   = TaxStateManagerFactory.Create();
            ProductManager  productManager = ProductManagerFactory.Create();
            Order           order          = new Order();
            DateTime        orderDate;
            string          stateInput, productInput, tempAreaInput;



            Console.Clear();
            Console.WriteLine("Edit an Order");
            Console.WriteLine("--------------------");



            //Get order date file
            Console.WriteLine("Please enter the Order Date you would like to edit");
            while (!DateTime.TryParse(Console.ReadLine(), out orderDate))
            {
                Console.WriteLine("That is not a valid format, please try again");
            }



            //display all orders
            OrderLookupResponse fileResponse = manager.AllOrderLookup(orderDate);

            if (fileResponse.Success)
            {
                foreach (Order entry in fileResponse.Orders)
                {
                    ConsoleIO.DisplayOrder(entry);
                }
            }
            Console.WriteLine();



            //get order number and make edits
            int orderNumberInput;

            Console.WriteLine("Enter the Order Number you'd like to edit:");
            while (!int.TryParse(Console.ReadLine(), out orderNumberInput))
            {
                Console.WriteLine("That is not a valid input.  Try again");
            }
            OrderLookupResponse response = manager.OrderLookup(orderDate, orderNumberInput);

            if (response.Success)
            {
                ConsoleIO.DisplayOrder(response.Order);
                order = response.Order;
                Console.WriteLine();

                Console.WriteLine("Please enter new values, entering nothing will keep current value.");



                //Edit Name
                NameCheckResponse nameResponse = new NameCheckResponse();
                Console.Write("Enter the Customer's Name:  ");
                string nameInput = Console.ReadLine().Replace(',', '|').Trim();
                nameResponse = inputManager.NameCheck(nameInput);
                if (nameInput != "")
                {
                    while (!nameResponse.Success)
                    {
                        nameResponse = inputManager.NameCheck(nameInput);
                        if (!nameResponse.Success)
                        {
                            Console.WriteLine(nameResponse.Message);
                            Console.Write("Name: ");
                            nameInput = Console.ReadLine();
                        }
                    }
                    order.CustomerName = nameInput;
                }
                Console.Clear();



                //Display States
                Console.WriteLine("These are the states in our system, please enter which state.");
                foreach (TaxState entry in stateManager.GetTaxStates())
                {
                    Console.WriteLine(entry.StateName);
                }

                //Edit State
                TaxStateLookupResponse  stateResponse      = new TaxStateLookupResponse();
                StateInputCheckResponse stateInputResponse = new StateInputCheckResponse();

                Console.WriteLine("Please enter new values, entering nothing will keep current value.");

                Console.Write("State: ");
                stateInput         = Console.ReadLine();
                stateInputResponse = inputManager.StateCheck(stateInput);
                if (stateInputResponse.Success)
                {
                    stateResponse.Success = false;
                    while (!stateResponse.Success)
                    {
                        stateResponse = stateManager.FindTaxState(stateInput);
                        if (!stateResponse.Success)
                        {
                            Console.WriteLine(stateResponse.Message);
                            Console.Write("State: ");
                            stateInput = Console.ReadLine();
                        }
                    }
                    order.State = stateInput;
                }
                Console.Clear();



                //Display Products
                Console.WriteLine("These are the materials availbale to choose from:");
                foreach (Product entry in productManager.GetProducts())
                {
                    Console.WriteLine(string.Format("{0},  Labor Cost: {1},  Material Cost: {2}",
                                                    entry.ProductType,
                                                    entry.LaborCostPerSquareFoot,
                                                    entry.CostPerSquareFoot));
                }

                //Edit Product
                ProductLookupResposnse    productResponse      = new ProductLookupResposnse();
                ProductInputCheckResponse productInputResponse = new ProductInputCheckResponse();
                Console.WriteLine("Please enter new values, entering nothing will keep current value.");

                Console.Write("Product Type: ");
                productInput         = Console.ReadLine();
                productInputResponse = inputManager.ProductCheck(productInput);
                if (productInputResponse.Success)
                {
                    productResponse.Success = false;
                    while (!productResponse.Success)
                    {
                        productResponse = productManager.FindProduct(productInput);
                        if (!productResponse.Success)
                        {
                            Console.WriteLine(productResponse.Message);
                            Console.Write("Product Type: ");
                            productInput = Console.ReadLine();
                        }
                    }
                    order.ProductType = productInput;
                }
                Console.Clear();



                //Edit Area
                AreaCheckResponse areaResponse = new AreaCheckResponse();
                Console.Write("Area: ");
                decimal areaInput;
                tempAreaInput = Console.ReadLine();
                if (tempAreaInput != "")
                {
                    areaResponse.Success = false;
                    while (!decimal.TryParse(tempAreaInput, out areaInput))
                    {
                        Console.WriteLine("That is not a valid input.");
                        Console.Write("Area: ");
                        tempAreaInput = Console.ReadLine();
                    }
                    while (!areaResponse.Success)
                    {
                        areaResponse = inputManager.AreaCheck(areaInput);
                        Console.WriteLine(areaResponse.Message);
                    }
                    order.Area = areaInput;
                }
                Console.Clear();



                if (stateInput == "" && productInput == "" && tempAreaInput == "")
                {
                    order = OrderCreation.EditedOrder(order.OrderDate, order.OrderNumber, order.CustomerName, order.State, order.StateAbv, order.TaxRate, order.ProductType, order.Area, order.CostPerSqaureFoot, order.LaborCostPerSquareFoot, order.MaterialCost, order.LaborCost, order.Tax, order.Total);
                }
                else
                {
                    order = OrderCreation.CreateOrder(order.OrderDate, order.OrderNumber, order.CustomerName, order.State, order.ProductType, order.Area);
                }
                ConsoleIO.DisplayOrder(order);
                Console.WriteLine();
                string answer = null;
                while (answer == null)
                {
                    Console.WriteLine("Do you want to save this order? (Y/N)");
                    answer = Console.ReadLine().ToUpper();
                    switch (answer)
                    {
                    case "Y":
                        manager.UpdateOrder(order);
                        Console.WriteLine("Order Saved");
                        break;

                    case "N":
                        Console.WriteLine("Order Not Saved");
                        break;

                    default:
                        Console.WriteLine("That is not a valid input, try again");
                        answer = null;
                        break;
                    }
                }
                Console.WriteLine("Press any key to continue...");
                Console.ReadKey();
                return;
            }
            else
            {
                Console.WriteLine("That Order does not currently exist in our system");
                Console.WriteLine("Press any key to continue...");
                Console.ReadKey();
                return;
            }
        }