public Response ValiDate(string userInput)
        {
            OrderManager manager  = OrderManagerFactory.Create();
            Response     response = new Response();
            DateTime     date;

            if (string.IsNullOrEmpty(userInput))
            {
                response.Success = false;
                response.Message = "This field cannot be left blank";
                return(response);
            }

            if (!DateTime.TryParse(userInput, out date))
            {
                response.Success = false;
                response.Message = "Please enter a valid date.";
                return(response);
            }
            else
            {
                response.Success = true;
                return(response);
            }
        }
        public static void Execute()
        {
            OrderManager  myOM      = OrderManagerFactory.Create(default(DateTime).Date); //Just accessing myOM to get a list of filenames, therefore using default system date
            List <string> fileNames = myOM.GetAllFileNames(out string dataPath);

            ConsoleIO.DisplayFilenames(fileNames, true, true, ConsoleColor.Blue);
        }
        public void CanEdit(string OrderDate, string NameInput, string StateInput, string ProductInput, decimal AreaInput, string NameEdit, string StateEdit, string ProductEdit, decimal AreaEdit, bool success)
        {
            OrderManager manager   = OrderManagerFactory.Create();
            DateTime     orderDate = DateTime.Parse(OrderDate);

            PlaceNewOrderResponse response = manager.NewOrder(orderDate, NameInput, StateInput, ProductInput, AreaInput);
            Order toEdit = new Order
            {
                OrderNumber            = response.Order.OrderNumber,
                OrderDate              = response.Order.OrderDate,
                CustomerName           = NameEdit,
                State                  = StateEdit,
                ProductType            = ProductEdit,
                Area                   = AreaEdit,
                CostPerSquareFoot      = 2.25m,
                LaborCostPerSquareFoot = 2.10m,
                MaterialCost           = 450.00m,
                LaborCost              = 420.00m,
                TotalTax               = 54.375m,
                Total                  = 924.375m
            };

            EditExistingOrderResponse editResponse = manager.EditOrder(toEdit);

            OrderLookupResponse loadResponse = manager.OrderLookup(response.Order.OrderNumber, orderDate);

            Assert.AreEqual(success, response.Success);
            Assert.AreEqual(loadResponse.Order.CustomerName, NameEdit);
            Assert.AreEqual(loadResponse.Order.State, StateEdit);
            Assert.AreEqual(loadResponse.Order.ProductType, ProductEdit);
            Assert.AreEqual(loadResponse.Order.Area, AreaEdit);
        }
        public void Exicute()
        {
            Console.Clear();
            AddOrderResponse addOrderResponse = new AddOrderResponse();
            OrderManager     orderManager     = OrderManagerFactory.Create();

            Console.WriteLine("Add order");
            Console.WriteLine("===============================");
            addOrderResponse = SubLogic.MakeValidOrder();

            if (addOrderResponse.Success)
            {
                Console.Clear();
                bool areYouSure = SubLogic.ConfirmOrderToAdd(addOrderResponse.OrderToAdd);
                if (areYouSure == true)
                {
                    addOrderResponse = orderManager.AddOrder(addOrderResponse.OrderToAdd);
                    Console.WriteLine(addOrderResponse.Message);
                    Console.WriteLine("press any key to continue");
                    Console.ReadKey();
                }
            }
            else
            {
                Console.WriteLine(addOrderResponse.Message);
                Console.WriteLine("press any key to continue");
                Console.ReadKey();
            }
        }
        public void Execute()
        {
            OrderManager manager = OrderManagerFactory.Create();

            Console.Clear();
            Console.WriteLine("Lookup an Order(s)");
            Console.WriteLine("--------------------------");
            string orderdate = ConsoleIO.EnterOrderdate("Enter an order date in mm/dd/yyyy format, example 01/12/2015: ");

            OrdersLookupResponse orderslookupresponse = manager.LookupOrders(orderdate);

            if (orderslookupresponse.Success)
            {
                foreach (Order order in orderslookupresponse.Orderlist)
                {
                    ConsoleIO.DisplayOrderDetails(order, orderdate);
                }
            }
            else
            {
                Console.WriteLine(orderslookupresponse.Message);
            }
            Console.WriteLine("Press any key to continue...");
            Console.ReadKey();
        }
Beispiel #6
0
        public void CanAddTestRules(string orderDate, int orderNum, string custName, string abbr, string product, decimal area, decimal matCost, decimal laborCost, decimal tax, decimal total)
        {
            TestRepository  repo     = new TestRepository();
            OrderManager    manager  = OrderManagerFactory.Create();
            AddEditResponse response = new AddEditResponse();

            Order order = new Order();

            order.OrderDate = orderDate;
            List <Order> orders = repo.GetOrder(order.OrderDate);


            order.OrderNumber  = orderNum;
            order.CustomerName = custName;
            order.State        = abbr;
            order.Type         = product;
            order.Area         = area;
            order.MaterialCost = matCost;
            order.LaborCost    = laborCost;
            order.Tax          = tax;
            order.Total        = total;

            response.product = manager.GetProd(response);
            response.tax     = manager.GetTax(response);
            response.order   = order;
            bool second = true;

            response = manager.Add(order, true);

            Assert.AreEqual(1, orders.Count);
            Assert.IsNotNull(response);
            Assert.IsFalse(response.Success);
        }
Beispiel #7
0
        public void Execute()
        {
            Console.Clear();
            ConsoleIO.HeadingLable("Order Lookup (ALL BY DATE)");
            DateTime orderDate = ConsoleIO.GetDateFromUser("Order Date (ex. MM/DD/YYYY): ");

            OrderManager           manager  = OrderManagerFactory.Create();
            OrderLookupAllResponse response = manager.LookupAllOrders(orderDate);

            Console.Clear();

            if (response.Success)
            {
                ConsoleIO.HeadingLable($"All Orders for {orderDate:MM/dd/yyyy}");
                foreach (Order o in response.Orders.OrderBy(o => o.OrderNumber))
                {
                    ConsoleIO.DisplayOrderInformation(o, true);
                }
            }
            else
            {
                ConsoleIO.RedMessage($"An Error Occured: {response.Message}");
            }
            Console.WriteLine("\nPress any key to continue...");
            Console.ReadKey();
        }
        public void Execute()
        {
            Console.Clear();

            IFileOrderRepo fileOrderRepo;

            Console.WriteLine("Remove an Order");
            Console.WriteLine("---------------------");
            Console.WriteLine("Enter an order date: ");

            string userInputDate = Console.ReadLine();

            if (string.IsNullOrEmpty(userInputDate))
            {
                Console.WriteLine("Error: User input was invalid...Hit any key to return to menu...");
                Console.ReadKey();
                return;
            }

            var path = ConsoleIO.UserDateValidateToString(userInputDate);

            OrderManager manager = OrderManagerFactory.Create(path);

            OrderLookupResponse respose = manager.LookupOrders(path);

            if (respose.Success)
            {
                ConsoleIO.DisplayOrderDetails(respose.orders, path);
            }
            else
            {
                Console.WriteLine("An error has occurred: ");
                Console.WriteLine(respose.Message);
            }

            int orderNumber = ConsoleIO.StringToInt("Which order would you like to remove? (Choose order by it's ORDER NUMBER): ");

            Console.Clear();

            fileOrderRepo = new FileOrderRepo(path);
            fileOrderRepo.LoadOrder();

            Orders Order = fileOrderRepo.ReadByOrderNumber(orderNumber);

            ConsoleIO.DisplayOrderDetails(new List <Orders> {
                Order
            }, path);

            if (ConsoleIO.Exit("Do you want to DELETE order? [Y/N]") == false)
            {
                return;
            }
            else
            {
                fileOrderRepo.Delete(Order.OrderNumber, Order);
            }

            Console.WriteLine("Press any key to continue...");
            Console.ReadKey();
        }
Beispiel #9
0
        public static Order CreateOrder(DateTime orderDateInput, int orderNumberInput, string customerNameInput, string stateInput, string productTypeInput, decimal areaInput)
        {
            Conversions     convert        = new Conversions();
            TaxStateManager stateManager   = TaxStateManagerFactory.Create();
            ProductManager  productManager = ProductManagerFactory.Create();
            OrderManager    manager        = OrderManagerFactory.Create();
            Order           order          = new Order();

            order.OrderDate              = orderDateInput;
            order.OrderNumber            = orderNumberInput;
            order.CustomerName           = customerNameInput;
            order.State                  = stateInput;
            order.StateAbv               = stateManager.FindTaxState(stateInput).TaxState.StateCode;
            order.TaxRate                = stateManager.FindTaxState(stateInput).TaxState.TaxRate;
            order.ProductType            = productManager.FindProduct(productTypeInput).Product.ProductType;
            order.Area                   = areaInput;
            order.CostPerSqaureFoot      = productManager.FindProduct(productTypeInput).Product.CostPerSquareFoot;
            order.LaborCostPerSquareFoot = productManager.FindProduct(productTypeInput).Product.LaborCostPerSquareFoot;
            order.MaterialCost           = convert.MaterialCost(order, productManager.FindProduct(productTypeInput).Product);
            order.LaborCost              = convert.LaborCost(order, productManager.FindProduct(productTypeInput).Product);
            order.Tax   = convert.Tax(order, stateManager.FindTaxState(stateInput).TaxState);
            order.Total = convert.Total(order);

            return(order);
        }
        public void Execute()
        {
            string date;

            do
            {
                Console.Clear();
                Console.Write("Enter Date <MM/DD/YYY>: ");
            } while (!Validation.OrderDateValidation(Console.ReadLine(), false, out date));

            OrderLookupResponse response = OrderManagerFactory.Create().LookupOrders(date);

            if (response.Success)
            {
                Console.Clear();

                foreach (var order in response.Orders)
                {
                    Console.WriteLine(border);

                    // information is pass into Display Method

                    Output.DisplayIO.DisplayOrderSummary(date, order);
                    Console.WriteLine(border);
                }
            }
            else
            {
                Console.WriteLine(response.Message);
            }
            Console.ReadKey();
        }
        internal void Execute()
        {
            OrderManager manager = OrderManagerFactory.Create();

            Console.Clear();
            Console.WriteLine("REMOVE AN ORDER");
            Console.WriteLine("*****************");
            Console.WriteLine();

            DateTime orderDate   = ConsoleIO.GetDate();
            int      orderNumber = ConsoleIO.GetOrderNumber();

            LoadOrderResponse response = manager.LoadRequestedOrder(orderDate, orderNumber);

            if (response.Success)
            {
                ConsoleIO.DisplaySingleOrderDetail(response.Order);
                Console.WriteLine();
                Console.WriteLine("Are you sure you want to delete the order above? Y/N");
                string userInput = Console.ReadLine().ToUpper();
                if (userInput == "Y")
                {
                    manager.RemoveOrder(response.Order);
                    Console.WriteLine("This order has been removed.");
                }
            }
            Console.WriteLine("Press any key to continue...");
            Console.ReadKey();
        }
Beispiel #12
0
        public static string GetStateInput(string state = "")
        {
            while (true)
            {
                OrderManager manager = OrderManagerFactory.Create();

                Console.Write("[" + state + "] Enter a state (ex. MN): ");

                string input = Console.ReadLine();

                if (state.ToLower() == input.ToLower() || input == null || input == "")
                {
                    return(state);
                }

                if (manager.Taxes.Any(x => x.StateAbbreviation == input.ToUpper()))
                {
                    return(input);
                }
                else
                {
                    Console.WriteLine("ERROR: Enter a valid state abbreviation.");
                }
            }
        }
Beispiel #13
0
        public static string GetProductInput(string productType = "")
        {
            while (true)
            {
                OrderManager manager = OrderManagerFactory.Create();

                Console.Write("[" + productType + "] Please enter a Product Type: ");

                string input = Console.ReadLine();

                if (input.ToLower() == productType.ToLower() || input == null || input == "")
                {
                    return(productType);
                }

                if (manager.Products.Any(x => x.ProductType.ToLower() == input.ToLower()))
                {
                    return(input);
                }
                else
                {
                    Console.WriteLine("ERROR: Enter a valid product type.");
                }
            }
        }
Beispiel #14
0
        public void Execute()
        {
            OrderManager manager = OrderManagerFactory.Create();

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



            DateTime            OrderDate   = ConsoleIO.GetRequiredDateFromUser("Enter a date (MMDDYYYY): ");
            int                 OrderNumber = ConsoleIO.GetRequiredIntFromUser("Enter an order number: ");
            LookupOrderResponse response    = manager.LookupOrder(OrderNumber, OrderDate);



            if (response.Order.Area == -1)
            {
                Console.WriteLine("The ordernumber entered does not exist ");
                Console.WriteLine("Press any key to continue... ");
            }

            else if (response.Order.Area == -2)
            {
                Console.WriteLine("We do not have a file for that date, try making one ");
                Console.WriteLine("Press any key to continue... ");
            }
            else
            {
                ConsoleIO.DisplayOrderDetails(response.Order);
            }
            Console.WriteLine("Press any key to continue...");
            Console.ReadKey();
        }
Beispiel #15
0
        public void CanEditTest(string orderDate, string custName, string abbr, string product, decimal area, bool expectedSuccess)
        {
            TestRepository  repo     = new TestRepository();
            OrderManager    manager  = OrderManagerFactory.Create();
            AddEditResponse response = new AddEditResponse();

            Order order = new Order();

            order.OrderDate = orderDate;
            List <Order> orders = repo.GetOrder(order.OrderDate);

            Order editOrder = orders[0];

            editOrder.CustomerName = custName;
            editOrder.Type         = product;
            editOrder.Area         = area;
            editOrder.State        = abbr;
            bool second = true;

            response         = manager.Edit(editOrder, second);
            response.product = manager.GetProd(response);
            response.tax     = manager.GetTax(response);

            orders = repo.GetOrder(order.OrderDate);

            Assert.AreEqual(1, orders.Count);
            Assert.AreEqual("Tim", orders[0].CustomerName);
            Assert.IsNotNull(response);
            Assert.AreEqual(expectedSuccess, response.Success);
        }
        public void Execute()
        {
            OrderManager       _manager  = OrderManagerFactory.Create();
            Order              order     = new Order();
            DisplayOrderToSave showOrder = new DisplayOrderToSave();

            Console.Clear();

            DateTime date = GetFromUser.GetDate();

            OrderResponse response = _manager.AddOrder(date);

            if (response.Success)
            {
                showOrder.Show(response.Order);
                _manager.SaveOrder(response.Order);
            }

            else
            {
                Console.WriteLine("An error has occurred.");
                Console.WriteLine(response.Message);
            }

            Console.WriteLine("Press any key to continue...");
            Console.ReadKey();
        }
Beispiel #17
0
        public void CanAddTest()
        {
            TestRepository  repo     = new TestRepository();
            OrderManager    manager  = OrderManagerFactory.Create();
            AddEditResponse response = new AddEditResponse();

            Order order = new Order();

            order.OrderDate = "06012019";
            List <Order> orders = repo.GetOrder(order.OrderDate);


            order.OrderNumber  = 1;
            order.CustomerName = "Tim";
            order.State        = "KY";
            order.Type         = "tile";
            order.Area         = 150;
            order.MaterialCost = 100M;
            order.LaborCost    = 150M;
            order.Tax          = 40M;
            order.Total        = 290M;

            response.product = manager.GetProd(response);
            response.tax     = manager.GetTax(response);
            bool second = true;

            response = manager.Add(order, second);
            orders   = repo.GetOrder(order.OrderDate);

            Assert.AreEqual(2, orders.Count);
            Assert.IsNotNull(response);
            Assert.IsTrue(response.Success);
        }
Beispiel #18
0
        public void Execute()
        {
            Console.Clear();
            var userEnteredDate = ConsoleIO.GetDate();

            var userEnteredOrderNumber = ConsoleIO.GetOrderNumber();

            OrderManager orderManager = OrderManagerFactory.Create();

            var response = orderManager.LookupOrder(userEnteredDate);

            var orderBeingRemoved = response.Order.SingleOrDefault(o => o.OrderNumber == userEnteredOrderNumber);

            ConsoleIO.DisplaySingleOrderDetails(orderBeingRemoved);
            Console.WriteLine("Are you sure you want to delete this Order : ");
            string delete = Console.ReadLine();

            if ((orderBeingRemoved == null) || (delete == "n") || (delete == "N"))
            {
                Console.WriteLine("We could not find that order or you selected not to delete");
                Console.ReadKey();
            }
            if (((delete == "y") || (delete == "Y")) && (orderBeingRemoved != null))
            {
                orderManager.RemoveOrder(orderBeingRemoved);
                Console.WriteLine("We deleted the order");
                Console.ReadKey();
            }
            else
            {
                Console.WriteLine("We could not find that order or you selected not to delete");
                Console.ReadKey();
            }
        }
Beispiel #19
0
        public void Execute()
        {
            Console.Clear();
            OrderManager manager = OrderManagerFactory.Create();

            Console.WriteLine();
            Console.WriteLine(ConsoleIO.SeperatorBar);
            Console.WriteLine(" EDIT ORDER MENU ");
            Console.WriteLine(ConsoleIO.SeperatorBar);
            Console.WriteLine();

            DateTime validatedDate        = ValidateDate();
            int      validatedOrderNumber = ValidateOrderNumber();

            DisplaySingleOrderResponse response = DisplayOrder(validatedDate, validatedOrderNumber, manager);

            if (response.Success)
            {
                ChangeName(response);
                ChangeState(response);
                ChangeProduct(response);
                ChangeArea(response, manager);
            }
            else
            {
                Console.WriteLine(ConsoleIO.ErrorMessage);
                Console.WriteLine(response.Message);
                Console.ReadKey();
            }
        }
        public void NewProduct(Order order)
        {
            OrderManager manager = OrderManagerFactory.Create();

            while (!isValid)
            {
                ProductRepo repo        = new ProductRepo();
                string      productType = ConsoleIO.GetProduct(repo.LoadProducts());
                Console.WriteLine($"Is this the correct new product: {productType}, Y/N?");
                string correctProduct = Console.ReadLine().ToUpper();
                if (correctProduct == "Y")
                {
                    isValid = true;
                }
                ProductTypeResponse response = manager.FindProductByType(productType);
                if (response.Success)
                {
                    manager.SaveCurrentOrder(order);
                    ConsoleIO.DisplayEditedOrderDetail(order);
                    Console.WriteLine("Press any key to continue...");
                    Console.ReadKey();
                }
                else
                {
                    response.Success = false;
                    response.Message = "An error occurred";
                    Console.WriteLine("Press any key to continue...");
                    Console.ReadKey();
                }
            }
        }
Beispiel #21
0
        public void Execute()
        {
            OrderManager manager = OrderManagerFactory.Create();

            Console.Clear();
            Console.WriteLine("Lookup Orders");
            Console.WriteLine("*********************************");
            Console.Write("Enter the date (mm/dd/yyyy) that you would like to view orders for: ");

            DateTime date;

            DateTime.TryParse(Console.ReadLine(), out date);

            OrderLookupResponse response = manager.LookupOrders(date);

            if (response.Success)
            {
                ConsoleIO.DisplayOrderDetails(response.ListOfOrders);
            }
            else
            {
                Console.WriteLine("An error occured: ");
                Console.WriteLine(response.Message);
            }
            Console.WriteLine("Press any key to continue...");
            Console.ReadKey();
        }
Beispiel #22
0
        internal void Execute()
        {
            OrderManager manager = OrderManagerFactory.Create();

            //clear console and get info from customer
            Console.Clear();

            //ask the user for date and order number to delete
            Console.WriteLine("Enter the order date(e.g. 'dd/mm/yyyy') for the order you'd like to delete: ");
            var userDateInput = manager.StringToDate(Console.ReadLine());

            Console.WriteLine("Enter the order number of the order you'd like to delete: ");
            var userOrderInput = int.Parse(Console.ReadLine()); //todo: tryParse would be better

            OrderResponse response = manager.LookupOrder(userDateInput, userOrderInput);

            if (response.Success == true)
            {
                ConsoleIO.DisplayOrderDetails(response.Order);
                var deleteResponse = ConsoleIO.DeleteConfirmation();
                manager.RemoveOrder(response.Order.OrderDate, response.Order.OrderNumber, deleteResponse);
            }
            else
            {
                Console.WriteLine(response.Message);
                Console.ReadKey();
            }
        }
Beispiel #23
0
        internal static void Execute(DisplayMode mode)
        {
            Console.Clear();
            if (!ConsoleIO.GetDateValue("Enter the date you wish to display orders for: ", null, out DateTime orderDate))
            {
                return;
            }
            OrderManager   myOM       = OrderManagerFactory.Create(orderDate);
            OrdersResponse responseOs = myOM.GetOrders();

            if (responseOs.Success)
            {
                ConsoleIO.DisplayOrders(mode, responseOs.Orders, ConsoleColor.Blue);
            }
            else
            {
                ConsoleIO.DisplayText(responseOs.Message, false, false, ConsoleColor.Red);
                if (responseOs.Orders.Count > 2) //Must have more than just header = 1 order to have other lines to display.
                {
                    if (!ConsoleIO.GetString($"Press (Y/y) if you wish to display other orders despite this error.", 1, out string input))
                    {
                        return;
                    }
                    if (input.ToUpper() == "Y")
                    {
                        ConsoleIO.DisplayOrders(mode, responseOs.Orders, ConsoleColor.Blue);
                    }
                }
                else
                {
                    ConsoleIO.DisplayText("Press any key to continue...", false, true);
                }
            }
        }
Beispiel #24
0
        public void CanEditExistingOrder(int orderNumber, string customerName, string state, string type, int area)
        {
            OrderManager manager = OrderManagerFactory.Create();

            LoadOrderResponse orderResponse = manager.LoadOrder("10/10/20", orderNumber);
            var editOrder = orderResponse.Order;

            Assert.AreEqual("Dave", editOrder.CustomerName);
            Assert.AreEqual("MI", editOrder.State);
            Assert.AreEqual("Wood", editOrder.FloorType);
            Assert.AreEqual(100, editOrder.Area);


            editOrder.CustomerName = customerName;
            editOrder.State        = state;
            editOrder.FloorType    = type;
            editOrder.Area         = area;

            manager.CalculateOrderCosts(editOrder);
            manager.EditOrder(editOrder, editOrder.OrderNumber - 1, "10/10/20");

            var orders = manager.LoadOrderList("10/10/20").Orders;

            Assert.AreEqual(customerName, orders[0].CustomerName);
            Assert.AreEqual(state, orders[0].State);
            Assert.AreEqual(type, orders[0].FloorType);
            Assert.AreEqual(area, orders[0].Area);
        }
Beispiel #25
0
        public void Execute()
        {
            OrderManager manager = OrderManagerFactory.Create();

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

            DateTime orderDate    = Input.GetOrderDateInput();
            string   customerName = Input.GetCustomerNameInput();
            string   state        = Input.GetStateInput();
            string   productType  = Input.GetProductInput();
            decimal  area         = Input.GetAreaInput();

            Order order = manager.GenerateOrder(orderDate, customerName, state, productType, area);

            Output.DisplayOrder(order);

            if (Input.ConfirmSubmisison())
            {
                manager.CreateOrder(order);
            }

            Console.WriteLine();
            Console.WriteLine("Press any key to continue...");
            Console.ReadKey();
        }
Beispiel #26
0
        public void Setup()
        {
            string mode = ConfigurationManager.AppSettings["Mode"].ToString();

            if (mode == "Prod")
            {
                if (File.Exists(_filePath))
                {
                    File.Delete(_filePath);
                }

                File.Copy(_original, _filePath);
            }
            else
            {
                OrderManager      manager       = OrderManagerFactory.Create();
                LoadOrderResponse orderResponse = manager.LoadOrder("10/10/20", 1);
                Order             testOrder     = orderResponse.Order;

                testOrder.OrderNumber            = 1;
                testOrder.CustomerName           = "Dave";
                testOrder.State                  = "MI";
                testOrder.TaxRate                = 5.75M;
                testOrder.FloorType              = "Wood";
                testOrder.Area                   = 100M;
                testOrder.CostPerSquareFoot      = 5.15M;
                testOrder.LaborCostPerSquareFoot = 4.75M;
                testOrder.MaterialCost           = 515.00M;
                testOrder.LaborCost              = 475.00M;
                testOrder.Tax   = 56.93M;
                testOrder.Total = 1046.925M;
            }
        }
Beispiel #27
0
        public void Execute()
        {
            OrderManager orderManager = OrderManagerFactory.Create();

            Console.Clear();
            Console.WriteLine("Display Orders");
            Console.WriteLine("--------------------------------");

            Console.Write("Enter order date: ");

            DateTime orderDate = ConsoleIO.GetRequiredDateFromUser("Enter order date. Ex. MM/DD/YYYYY : ");

            DisplayOrderResponse response = orderManager.DisplayOrder(orderDate);

            if (response.Success)
            {
                ConsoleIO.DisplayListOrderDetails(response.ListOfOrders);
            }
            else
            {
                Console.WriteLine("An error occurerd: ");
                Console.WriteLine(response.Message);
            }

            Console.WriteLine("Press any key to continue...");
            Console.ReadKey();
        }
Beispiel #28
0
        public void CanAddOrderToRepo(string customerName, string state, string type, int area, string orderDate, bool expectedResult)
        {
            OrderManager manager = OrderManagerFactory.Create();

            Order newOrder = new Order()
            {
                CustomerName = customerName,
                State        = state,
                FloorType    = type,
                Area         = area
            };

            LoadOrderResponse addResponse = manager.LoadNewOrder(newOrder, orderDate);

            Assert.AreEqual(expectedResult, addResponse.Success);

            if (addResponse.Success)
            {
                manager.AddNewOrder(newOrder, orderDate);

                LoadOrderListResponse response = manager.LoadOrderList("10/10/20");
                var orders = response.Orders;

                Order check = orders[1];

                Assert.AreEqual("Test Man", check.CustomerName);
                Assert.AreEqual("Tile", check.FloorType);
                Assert.AreEqual(105, check.Area);
            }
        }
        public void Execute()
        {
            OrderManager manager = OrderManagerFactory.Create();

            Console.Clear();
            Console.WriteLine("Remove order");
            Console.WriteLine("--------------------------");
            Console.Write("Enter the order date (DDMMYYYY):");
            string orderDate = Console.ReadLine();

            Console.Write("Enter the order number: ");
            string orderNumber = Console.ReadLine();

            Response response = manager.RemoveOrder(orderDate, orderNumber);

            if (!response.Success)
            {
                Console.WriteLine("An error occurred: ");
            }

            Console.WriteLine(response.Message);

            Console.WriteLine("Press any key to continue...");
            Console.ReadKey();
        }
        public void Execute()
        {
            OrderManager manager = OrderManagerFactory.Create();
            IUserIO      io      = new ConsoleIO(); //This can be replaced with a factory if we ever use multiple IO types

            io.Clear();
            io.WriteLine("Order Removal");
            io.WriteLine(new string('*', 27));
            DateTime targetDate = io.GetDate("Enter the date of the order to remove: ").Date;
            int      targetNum  = io.GetInt("Enter the order number to remove: ");
            string   result     = "";

            if (manager.TryGetOrder(targetNum, targetDate, out Order target))
            {
                io.Clear();
                io.WriteLine("Search result:");
                io.WriteLine(target.GetFullOrderString());
                bool confirm = io.GetBool("Are you sure you would like to delete this order?");

                if (confirm)
                {
                    result = manager.DeleteOrder(target);
                }
                else
                {
                    result = "Removal cancelled.";
                }
            }
            else
            {
                result = "No order found with given parameters. Returning to menu.";
            }
            io.WriteLine(result);
            io.WaitForUser("Press any key to continue...");
        }