Пример #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
 /// <summary>
 /// Gets the detailed order information
 /// </summary>
 /// <param name="orderNumber">Number of order you want to display</param>
 /// <param name="date">Date where the repo lives</param>
 /// <returns>an order</returns>
 private static CustomerOrder RetreiveOrderByNumber(int orderNumber, string date)
 {
     var ops = new OrderManager();
     var response = ops.DisplayCustomerOrder(orderNumber, date);
     if (response.Success)
     {
         return response.Order;
     }
     Console.WriteLine("Error Occurred!!!!");
     Console.WriteLine(response.Message);
     Console.WriteLine("Go away now...");
     Console.ReadLine();
     return null;
 }
Пример #4
0
        /// <summary>
        /// Displays all orders in list of orders
        /// <param name="headerText">Text you want to show in the header</param>
        /// </summary>
        public void Orders(string headerText, string date)
        {
            var ops = new OrderManager();
            string headFormat = "{0, 1}. {1, -20} Total: {2,-10:C}";
            int orderNumber = 0;

            _wrappers.DrawHeader(headerText);

            foreach (var order in ops.GetAllOrders(date))
            {
                orderNumber++;
                Console.WriteLine(headFormat, orderNumber, order.CustomerName, order.OrderTotal);

            }
            _wrappers.DrawFooter();
            Console.WriteLine();
        }
Пример #5
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);
        }
Пример #6
0
        /// <summary>
        /// Displays a list of all orders, prompts the user to choose one to see detailed information about it
        /// </summary>
        public void Execute()
        {
            Console.Clear();
            _prompts.SetHeaderText("Display Order");

            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);
            var orderManager = new OrderManager();

            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;
            }

            var customerOrder = RetreiveOrderByNumber(orderNumber, date);

            Console.Clear();

            _orderForm.DisplayFullOrder(customerOrder, $"Order #{customerOrder.OrderNumber}");
            Console.WriteLine();
            Console.Write("Press any key to go back to the main menu...");
            Console.ReadKey();
        }
Пример #7
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;
                }
            }
        }
Пример #8
0
        public void SetOrderNumberTest()
        {
            var orderManager = new OrderManager();
            var testOrder = new CustomerOrder();
            testOrder = orderManager.SetOrderNumber(_order, _date);

            Assert.AreEqual(4, testOrder.OrderNumber);
        }
Пример #9
0
 public void RemoveOrderFromRepoTest()
 {
     var orderManager = new OrderManager();
     orderManager.RemoveOrder(3, _date);
        Assert.AreEqual(2,orderManager.NumberOfOrdersInRepo(_date));
 }
Пример #10
0
 public void NumberOfOrdersInRepoFail()
 {
     var orderManager = new OrderManager();
     int numberOforders = orderManager.NumberOfOrdersInRepo(_date);
     Assert.AreNotEqual(3, numberOforders);
 }
Пример #11
0
 public void AddOrderToRepoTest()
 {
     var orderManager = new OrderManager();
     orderManager.AddOrderToRepo(_order,_date);
     Assert.AreEqual(4,orderManager.NumberOfOrdersInRepo(_date));
 }
Пример #12
0
        public void Execute()
        {
            Console.Clear();

            var orderManager = new OrderManager();

            _displayFullList.Products();
            _prompts.SetHeaderText("Remove Order");

            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();
            _orderForm.DisplayFullOrder(orderResponse.Order, $"Remove Order?");
            Console.WriteLine();
            while (true)
            {
                Console.Write("Are you sure you want to remove this order? (Y/N) ");
                switch (Console.ReadKey(false).Key)
                {
                    case ConsoleKey.Y:
                        Console.Clear();
                        orderManager.RemoveOrder(orderNumber, date);
                        _wrappers.DrawHeader("Order has been removed");
                        _wrappers.DrawFooter();
                        Thread.Sleep(1000);
                        return;
                    case ConsoleKey.N:
                        Console.Clear();
                        _wrappers.DrawHeader("Order has not been removed");
                        _wrappers.DrawFooter();
                        Thread.Sleep(1000);
                        return;
                    default:
                        Console.Clear();
                        _orderForm.DisplayFullOrder(orderResponse.Order, $"Remove Order #{orderNumber}?");
                        Console.WriteLine();
                        Console.WriteLine("Please press the Y or N key...");
                        continue;
                }
            }
        }