public void Execute()
        {
            OrderManager manager = new OrderManager();

            Console.Clear();

            string date = GetDate();
            var response = manager.GetOrders(date);

            Console.Clear();

            if (response.Success)
            {
                PrintOrders(response.Data, date);
            }

            else
            {
                Console.Clear();
                Console.WriteLine(response.Message);
            }

            Console.Write("Press any key to continue...");
            Console.ReadKey();
        }
        public void Execute()
        {
            OrderManager manager = new OrderManager();

            string date = GetDate();
            manager.GetOrderFile(date);
        }
Ejemplo n.º 3
0
        public Product IsProductTypeValid(string input, string promptUser)
        {
            OrderManager manager = new OrderManager();
            var materials = manager.GetMaterials();
            var products = materials.Select(mat => mat.ProductType).ToList();

            do
            {
                input = NotNull(input, promptUser);
                input = input.Substring(0, 1).ToUpper() + input.Substring(1, input.Length - 1).ToLower();

                if (products.Contains(input))
                {
                    var input1 = input;
                    var product = materials.Where(mat => mat.ProductType == input1).ToList();

                    return product[0];
                }

                Console.Clear();
                Console.WriteLine("That material is not available.\n");
                Console.Write(promptUser);
                input = Console.ReadLine();
            } while (true);
        }
Ejemplo n.º 4
0
        public void GetOrdersTestSuccess()
        {
            var manager  = new OrderManager();

            var response = manager.GetOrders("06012013");
            bool Success = response.Success;

            Assert.AreEqual(true, Success);
        }
Ejemplo n.º 5
0
        public void Execute()
        {
            OrderManager manager = new OrderManager();

            string date;
            Order selectedOrder;

            do
            {
                date = GetDate();
                var orderNumber = GetOrderNumber();
                selectedOrder = manager.GetOrder(date, orderNumber);

                if (selectedOrder == null)
                {
                    Console.Clear();
                    Console.WriteLine("Order does not exist.");
                    Console.Write("\nPress any key to continue, or (Q) to return to main menu...");

                    string input = Console.ReadLine();

                    if (input != null && input.ToUpper() == "Q")
                        return;
                }
            } while (selectedOrder == null);

            PrintOrder(selectedOrder);

            Console.Write("\nPress enter to begin editing...");
            Console.ReadLine();

            selectedOrder = GetCustomerName(selectedOrder);
            selectedOrder = GetState(selectedOrder);
            selectedOrder = GetProductType(selectedOrder);
            selectedOrder = GetArea(selectedOrder);

            var response = manager.EditOrder(selectedOrder, date);

            if (response.Success)
            {
                Console.Clear();
                Console.WriteLine(response.Message);
                Console.WriteLine();
                PrintEditedOrder(response.Data);
            }
            else
            {
                Console.Clear();
                Console.WriteLine("Something happened.");
                Console.WriteLine(response.Message);
            }

            Console.Write("\nPress any key to continue...");
            Console.ReadKey();
        }
Ejemplo n.º 6
0
        public void EditOrderComputationTest()
        {
            string d = "06012013";
            string expected = "Po";

            var manager = new OrderManager();
            MockOrdersRepo repo = new MockOrdersRepo();
            Order orderToEdit= repo.GetAllOrders(d)[1];

            orderToEdit.Name = expected;

            var editedOrder = manager.EditOrder(orderToEdit, d);

            Assert.AreEqual(expected, editedOrder.Data.Name);
        }
Ejemplo n.º 7
0
        public void Execute()
        {
            OrderManager manager = new OrderManager();

            Order orderToRemove;
            string date;

            do
            {
                date = GetDate();
                var orderNumber = GetOrderNumber();
                orderToRemove = manager.GetOrder(date, orderNumber);

                if (orderToRemove == null)
                {
                    Console.Clear();
                    Console.WriteLine("Order does not exist.");
                    Console.Write("\nPress any key to continue, or (Q) to return to main menu...");

                    string input = Console.ReadLine();

                    if (input != null && input.ToUpper() == "Q")
                        return;
                }
            } while (orderToRemove == null);

            PrintOrderToRemove(orderToRemove);

            if (!GetConfirmation())
                return;

            var response = manager.RemoveOrder(date, orderToRemove);

            if (response.Success)
            {
                Console.Clear();
                Console.WriteLine(response.Message);
            }
            else
            {
                Console.Clear();
                Console.WriteLine("A problem occurred...");
                Console.WriteLine(response.Message);
            }

            Console.Write("Press any key to continue...");
            Console.ReadKey();
        }
Ejemplo n.º 8
0
        public void AddOrderTest()
        {
            var manager = new OrderManager();
            var newOrder = new Order()
            {
                Area = 10,
                CostPerSquareFoot = 5.15M,
                LaborCostPerSquareFoot = 4.75M,
                Name = "Nick",
                OrderNumber = 0,
                ProductType = "Wood",
                StateAbbr = "PA",
                TaxRate = 6.75M,
            };

            var order = manager.AddOrder(newOrder);

            Assert.AreEqual("Nick", newOrder.Name);
        }
Ejemplo n.º 9
0
        public void Execute()
        {
            OrderManager manager = new OrderManager();
            Order newOrder = new Order();

            newOrder.Name = GetCustomerName();

            Tax newTax = GetState();
            Product newProduct = GetProductType();

            newOrder.Area = GetArea();
            newOrder.StateAbbr = newTax.StateAbbr;
            newOrder.TaxRate = newTax.TaxRate;
            newOrder.ProductType = newProduct.ProductType;
            newOrder.CostPerSquareFoot = newProduct.CostPerSqFt;
            newOrder.LaborCostPerSquareFoot = newProduct.LaborCostPerSqFt;

            Console.Clear();
            Console.WriteLine("New order information:\n");
            Console.WriteLine("{0, -9} - Name\n{1, -9} - State\n{2, -9} - Material\n{3, -9} - Area\n",
                newOrder.Name, newOrder.StateAbbr, newOrder.ProductType, newOrder.Area);

            if (!GetConfirmation())
                return;

            var response = manager.AddOrder(newOrder);

            if (response.Success)
            {
                Console.Clear();
                Console.WriteLine(response.Message);
                PrintNewOrder(response.Data);
            }
            else
            {
                Console.Clear();
                Console.WriteLine("Something happened when trying to add the order.");
                Console.WriteLine(response.Message);
            }

            Console.Write("Press any key to return to the menu...");
            Console.ReadKey();
        }
Ejemplo n.º 10
0
        public void AddOrderComputationTest()
        {
            var manager = new OrderManager();
            var newOrder = new Order()
            {
                Area = 10,
                CostPerSquareFoot = 5.15M,
                LaborCostPerSquareFoot = 4.75M,
                Name = "nick",
                OrderNumber = 0,
                ProductType = "Wood",
                StateAbbr = "PA",
                TaxRate = 6.75M,
            };

            var order = manager.AddOrder(newOrder);

            Assert.AreEqual(47.5M, newOrder.LaborCost);
            Assert.AreEqual(51.5M, newOrder.MaterialCost);
            Assert.AreEqual(105.6825, newOrder.TotalCost);
            Assert.AreEqual(6.6825, newOrder.TaxCost);
        }
Ejemplo n.º 11
0
        public void GetOrderTest()
        {
            var manager = new OrderManager();

            var order = manager.GetOrder("06012013", 1);

            Assert.AreEqual("Wise", order.Name);
        }
Ejemplo n.º 12
0
        public void RemoveOrderTest()
        {
            string d = "06012013";

            var manager = new OrderManager();
            MockOrdersRepo repo = new MockOrdersRepo();
            List<Order> OldOrders = repo.GetAllOrders(d);
            Order orderToRemove = repo.GetAllOrders(d)[0];

            manager.RemoveOrder(d, orderToRemove);
            List<Order> expected = repo.GetAllOrders(d);

            Assert.False(OldOrders.Contains(orderToRemove));
        }
Ejemplo n.º 13
0
        public Tax IsStateValid(string input, string promptUser)
        {
            OrderManager manager = new OrderManager();
            var states = manager.GetStates();
            var stateAbbrvs = states.Select(st => st.StateAbbr).ToList();

            do
            {
                input = NotNull(input, promptUser);
                input = input.ToUpper();

                if (stateAbbrvs.Contains(input))
                {
                    var input1 = input;
                    var tax = states.Where(mat => mat.StateAbbr == input1).ToList();

                    return tax[0];
                }

                Console.Clear();
                Console.WriteLine("That was not an avaiable location.\n");
                Console.Write(promptUser);
                input = Console.ReadLine();
            } while (true);
        }