示例#1
0
        public void Execute()
        {
            CustomerOrder order = new CustomerOrder();
            OrderManager orderManager = new OrderManager();
            Prompts prompts = new Prompts();
            Wrappers wrappers = new Wrappers();

            _headerText = "Add Order";

            string date = $"{DateTime.Today.Month.ToString()}{DateTime.Today.Day.ToString()}{DateTime.Today.Year.ToString()}";

            Console.Clear();

            prompts.SetHeaderText(_headerText);

            order = prompts.GetNameFromCustomer(order);
            order = prompts.GetStateFromCustomer(order);
            order = prompts.GetProductFromCustomer(order);
            order = prompts.GetAreaFromCustomer(order);

            Console.Clear();
            _orderForm.AddOrder(order, _headerText);

            order = orderManager.SetOrderNumber(order, date);
            order = orderManager.OrderCalculations(order);
            Console.Clear();
            _orderForm.DisplayFullOrder(order, _headerText);
            Console.WriteLine();

            while (true)
            {
                Console.WriteLine("Would you like to save this order? (Y/N)");

                switch (Console.ReadKey(false).Key)
                {
                    case ConsoleKey.Y:
                        orderManager.AddOrderToRepo(order, date);
                        Console.Clear();
                        wrappers.DrawHeader("Order Saved");
                        wrappers.DrawFooter();
                        Thread.Sleep(1000);
                        return;
                    case ConsoleKey.N:
                        Console.Clear();
                        wrappers.DrawHeader("Order not Saved");
                        wrappers.DrawFooter();
                        Thread.Sleep(1000);
                        return;
                    default:
                        Console.Clear();
                        _orderForm.DisplayFullOrder(order, _headerText);
                        Console.WriteLine();
                        Console.WriteLine("Press Y to save or N to abandon the order...");
                        break;
                }
            }
        }
示例#2
0
 /// <summary>
 /// Displays order with all the details
 /// </summary>
 /// <param name="order">The order you want to display.</param>
 /// <param name="headerText">What you want the header to say.</param>
 public void DisplayFullOrder(CustomerOrder order, string headerText)
 {
     OrderManager orderManager = new OrderManager();
     order = orderManager.OrderCalculations(order);
     _wrappers.DrawHeader(headerText);
     DrawCustomerInformation(order);
     DrawProductInformation(order);
     DrawTotalInformation(order);
     _wrappers.DrawFooter();
 }
示例#3
0
        public void OrderCalculationsTest()
        {
            var orderManager = new OrderManager();
            CustomerOrder testOrder = new CustomerOrder();
            StateManager stateManager = new StateManager();
            ProductManager productManager = new ProductManager();

            testOrder = orderManager.OrderCalculations(_order);
            var productResponse = productManager.GetProductResponse(_order.ProductKey);
            var laborCost = productResponse.Product.LaborCostSqFt;
            var materialCost = productResponse.Product.MaterialCostSqFt;
            var stateResponse = stateManager.GetStateResponse(_order.StateKey);

            var subTotal = (_order.Area * (materialCost + laborCost));
            var tax = subTotal/stateResponse.State.TaxRate;
            var total = subTotal + tax;

            Assert.AreEqual(total, testOrder.OrderTotal);
        }
示例#4
0
        public void Execute()
        {
            Console.Clear();
            var orderManager = new OrderManager();
            _prompts.EditMode();
            _prompts.SetHeaderText(HeaderText);

            string date = _prompts.GetDateFromCustomer();

            if (date == null)
            {
                Console.Clear();
                _wrappers.DrawHeader("Invalid date");
                Console.WriteLine("Returning to the main menu");
                _wrappers.DrawFooter();
                Thread.Sleep(1000);
                return;
            }

            int orderNumber = _prompts.GetOrderNumberFromUser(date);

            if (orderNumber < 0 || orderNumber > orderManager.NumberOfOrdersInRepo(date))
            {
                Console.Clear();
                _wrappers.DrawHeader("Invalid Entry...");
                Console.WriteLine("Returning to the main menu");
                _wrappers.DrawFooter();
                Thread.Sleep(1000);
                return;
            }

            CustomerOrderResponse orderResponse = orderManager.DisplayCustomerOrder(orderNumber, date);

            if (!orderResponse.Success)
            {
                Console.Clear();
                _wrappers.DrawHeader(orderResponse.Message);
                _wrappers.DrawFooter();
                Thread.Sleep(1000);
                return;
            }

            Console.Clear();

            CustomerOrder orderEdit = new CustomerOrder();

            _prompts.SetHeaderText(HeaderText);
            //_orderForm.AddOrder(orderEdit, HeaderText);

            CustomerOrder order = orderResponse.Order;
            orderManager.OrderCalculations(order);
            //sets the new values to the old ones for reuse
            orderEdit.CustomerName = order.CustomerName;
            orderEdit.AreaString = order.AreaString;
            orderEdit.Area = order.Area;
            orderEdit.StateKey = order.StateKey;
            orderEdit.ProductKey = order.ProductKey;
            orderEdit.OrderNumber = order.OrderNumber;

            _orderForm.AddOrder(orderEdit, HeaderText);
            orderEdit = _prompts.GetNameFromCustomer(orderEdit);
            Console.Clear();
            _orderForm.AddOrder(orderEdit, HeaderText);
            orderEdit = _prompts.GetStateFromCustomer(orderEdit);
            Console.Clear();
            _orderForm.AddOrder(orderEdit, HeaderText);
            orderEdit = _prompts.GetProductFromCustomer(orderEdit);
            Console.Clear();
            _orderForm.AddOrder(orderEdit, HeaderText);
            orderEdit = _prompts.GetAreaFromCustomer(orderEdit);

            Console.Clear();
            orderEdit = orderManager.OrderCalculations(orderEdit);
            _orderForm.DisplayFullOrder(orderEdit, HeaderText);

            while(true)
            {
                Console.WriteLine("Save edited order (Y/N)");
                switch (Console.ReadKey(false).Key)
                {
                    case ConsoleKey.Y:

                        orderManager.EditOrder(orderEdit, orderNumber, date);
                        Console.Clear();
                        _wrappers.DrawHeader("Changes saved");
                        _wrappers.DrawFooter();
                        Thread.Sleep(1000);
                        return;
                    case ConsoleKey.N:
                        Console.Clear();
                        _wrappers.DrawHeader("Changes not saved");
                        _wrappers.DrawFooter();
                        Thread.Sleep(1000);
                        return;
                    default:
                        Console.Clear();
                        _orderForm.AddOrder(orderEdit, HeaderText);
                        Console.WriteLine("Press either Y or N");
                        continue;
                }
            }
        }