예제 #1
0
        public void Execute()
        {
            var userQuestions = new UserQuestions();
            var orderManager = new OrderManager();
            var displayWF = new DisplayOrdersWF();

            var date = userQuestions.GetDateIfValidFile();

            var orderNumber = userQuestions.GetOrderNumberIfExists(date);

            var order = orderManager.LoadOrder(orderNumber, date);

            Console.WriteLine("This is the order you wish to remove:");
            Console.WriteLine("-----------------------------------");
            displayWF.PrintSingleOrder(order);

            bool wishToRemove = userQuestions.Confirmation("\nAre you sure you wish to delete this order?");

            if (wishToRemove)
            {
                orderManager.RemoveOrder(orderNumber, date);
                Console.WriteLine("You successfully removed the order.");
                Console.WriteLine("Press any key to continue...");
                Console.ReadKey();
            }
            else
            {
                Console.WriteLine("The order was not removed.");
                Console.WriteLine("Press any key to continue...");
                Console.ReadKey();
            }
        }
        public void Execute()
        {
            var date = GetDate();
            var ordernumber = GetOrderNumber();
            var manager = new OrderManager();
            var response = manager.DisplayOrders(date);
            if (response.Data == null || response.Data.Orders.Count == 0)
            {
                Console.WriteLine();
                Console.WriteLine("Sorry! There are no orders to delete from that date...");
                Console.Write("Press any key to continue... ");
                Console.ReadKey();
            }
            else
            {
                var ordertofind = response.Data.Orders.FirstOrDefault(a => a.orderNumber == ordernumber);
                if (ordertofind == null)
                {
                    Console.WriteLine();
                    Console.Write("Order#{0} was not found. Press any key to continue... ", ordernumber);
                    Console.ReadKey();
                }
                else
                {
                    // we found the correct order to delete.
                    Console.Clear();
                    Console.WriteLine("DELETE ORDER SUMMARY");
                    Console.WriteLine("*****************");
                    Console.WriteLine("orderNumber  customerName  stateName  taxRate  productType  Area    CostPerSquareFoot LaborCostPerSquareFoot MaterialCost LaborCost Tax    Total");

                    const string formatremove = "{0,-10} {1,11} {2,6} {3,12} {4,14} {5,8:n2} {6,5:n2} {7,17:n2} {8,24:n2} {9,12:n2} {10,8:n2} {11,9:n2}";
                    string line1 = string.Format(formatremove, ordertofind.orderNumber,
                        ordertofind.customerName, ordertofind.stateName,
                        ordertofind.taxRate, ordertofind.productType,
                        ordertofind.Area, ordertofind.CostPerSquareFoot,
                        ordertofind.LaborCostPerSquareFoot,
                        ordertofind.MaterialCost, ordertofind.LaborCost,
                        ordertofind.Tax, ordertofind.Total);

                    Console.WriteLine(line1);
                    Console.WriteLine();

                    // Delete order (y/n)
                    bool prompt = false;
                    string newgame = "";
                    while (prompt == false)
                    {
                        Console.Write("\nDelete entire order. Are you sure? (Y/N): ");
                        newgame = Console.ReadLine();
                        if (newgame.ToUpper() == "Y" || newgame.ToUpper() == "YES"
                            || newgame.ToUpper() == "N" || newgame.ToUpper() == "NO")
                        {
                            prompt = true;
                        }
                    }
                    if (newgame.ToUpper() == "Y" || newgame.ToUpper() == "YES")
                    {

                        manager.RemoveOrder(ordertofind, date, ordernumber);
                        Console.Write("Order has been deleted. Press any key to continue...");
                        Console.ReadKey();
                    }
                    else
                    {
                        Console.Write("Order not deleted. Press any key to continue...");
                        Console.ReadKey();
                    }
                }
            }
        }
예제 #3
0
        public void Execute()
        {
            Console.Clear();
            string Date = GetDate();
            Console.Clear();
            string CustomerName = GetCustomerName();
            Console.Clear();
            string StateName = GetStateName();
            Console.Clear();
            string ProductType = GetProductType();
            Console.Clear();
            decimal Area = GetArea();
            Console.Clear();
            var manager = new OrderManager();
            var order = new Order();
            order.customerName = CustomerName;
            order.stateName = StateName;
            order.productType = ProductType;
            order.Area = Area;

            var response = manager.AddOrder(order, Date);
            if (response.Data.Orders == null || response.Data.Orders.Count < 1)
            {
                Console.WriteLine("Blah...");
            }
            var neworder = response.Data.Order;
            Console.WriteLine();
            Console.WriteLine("NEW ORDER SUMMARY");
            Console.WriteLine("*****************");
            Console.WriteLine("orderNumber  customerName  stateName  taxRate  productType  Area    CostPerSquareFoot LaborCostPerSquareFoot MaterialCost LaborCost Tax    Total");
            const string formataddorder = "{0,1} {1,15} {2,11} {3,12} {4,10} {5,8:n2} {6,9} {7,17} {8,24} {9,11} {10,8:n2} {11,7:n2}";
            string line1 = string.Format(formataddorder, "#", neworder.customerName, neworder.stateName,
                                      neworder.taxRate, neworder.productType,
                                      neworder.Area, neworder.CostPerSquareFoot,
                                      neworder.LaborCostPerSquareFoot,
                                      neworder.MaterialCost, neworder.LaborCost,
                                      neworder.Tax, neworder.Total);

            Console.WriteLine(line1);
            Console.WriteLine();

            bool prompt = false;
            string newgame = "";
            while (prompt == false)
            {
                Console.Write("Commit new order? (Y/N): ");
                newgame = Console.ReadLine();
                if (newgame.ToUpper() == "Y" || newgame.ToUpper() == "YES"
                    || newgame.ToUpper() == "N" || newgame.ToUpper() == "NO")
                {
                    prompt = true;
                }
            }
            if (newgame.ToUpper() == "Y" || newgame.ToUpper() == "YES")
            {
                Console.Write("Order added to the system. Press any key to continue...");
                Console.ReadKey();
            }
            else
            {

                manager.RemoveOrder(neworder, Date, neworder.orderNumber);
                Console.Write("Order has been cancelled! Press any key to continue...");
                Console.ReadKey();
            }
        }
예제 #4
0
 public void RemoveOrderTest()
 {
     // arrange
     var manager = new OrderManager();
     var response = manager.DisplayOrders("09222015");
     // act
     var count = response.Data.Orders.Count;
     var orders = response.Data.Orders;
     var order1 = orders.Single(a => a.orderNumber == 1);
     manager.RemoveOrder(order1, "09222015", 1);
     var response2 = manager.DisplayOrders("09222015");
     var count2 = response2.Data.Orders.Count;
     // assert
     Assert.AreNotEqual(count, count2);
 }