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

            do
            {
                var date = userQuestions.AskDate();
                var response = orderManager.DisplayOrders(date);

                if (response.Success)
                {
                    PrintOrders(response.Data);
                    Console.ReadLine();
                    break;
                }

                    Console.WriteLine("A file with that date does not exist. Please try again.");
                    Console.WriteLine("Press enter to continue, or (Q) to quit.");

                    var answer = Console.ReadLine();
                    if (answer.ToUpper() == "Q")
                       break;

                    Console.Clear();

            } while (true);
        }
예제 #2
0
 public void DisplayOrderTest()
 {
     // arrange
     var manager = new OrderManager();
     var response = manager.DisplayOrders("09222015");
     // act
     var count = response.Data.Orders.Count;
     // assert
     Assert.AreEqual(count, 2);
 }
        public void Execute()
        {
            var date = GetDate();
            var manager = new OrderManager();
            var response = manager.DisplayOrders(date);
            if (response.Success)
            {
                Console.Clear();
                Console.WriteLine("orderNumber  customerName  stateName  taxRate  productType  Area    CostPerSquareFoot LaborCostPerSquareFoot MaterialCost LaborCost Tax   Total");

                const string format = "{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,8:n2}";

                foreach (var order in response.Data.Orders)
                {
                    string line1 = string.Format(format, order.orderNumber,
                        order.customerName, order.stateName,
                        order.taxRate, order.productType,
                        order.Area, order.CostPerSquareFoot,
                        order.LaborCostPerSquareFoot,
                        order.MaterialCost, order.LaborCost,
                        order.Tax, order.Total);

                    Console.WriteLine(line1);

                }
                Console.Write("\nPress any key to continue... ");
                Console.ReadKey();
            }
            else
            {
                Console.Clear();
                Console.WriteLine(response.Message);
                Console.Write("\nPress 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();
                    }
                }
            }
        }
예제 #5
0
        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 at all for that particular 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.
                    Console.Clear();
                    Console.WriteLine("EDIT ORDER SUMMARY");
                    Console.WriteLine("*****************");
                    Console.WriteLine("orderNumber  customerName  stateName  taxRate  productType  Area    CostPerSquareFoot LaborCostPerSquareFoot MaterialCost LaborCost Tax   Total");
                    const string formatordertofind = "{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,7:n2}";
                    string line2 = string.Format(formatordertofind, 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(line2);
                    Console.WriteLine();
                    Console.Write("\nPress ENTER to edit... ");
                    Console.ReadLine();
                    Console.WriteLine();

                    var ordertoedit = new Order();

                    //Update Customer Name
                    string inputname;
                    do
                    {
                        Console.Write("Enter customer name ({0}): ", ordertofind.customerName);
                        inputname = Console.ReadLine();
                    } while (inputname.Contains(",") || inputname.Contains("."));

                    if (inputname != "")
                    {
                        ordertoedit.customerName = inputname;
                    }
                    if (inputname == "")
                    {
                        ordertoedit.customerName = ordertofind.customerName;
                    }

                    // Update State Name
                    ordertoedit.stateName = GetStateName(ordertofind);

                    // Update Product Type
                    ordertoedit.productType = GetProductType(ordertofind);
                    ordertoedit.orderNumber = ordertofind.orderNumber;
                    // Update Area
                    do
                    {
                        Console.Write("Enter area greater than zero ({0}): ", ordertofind.Area);
                        string inputarea = Console.ReadLine();
                        decimal num;
                        bool test = decimal.TryParse(inputarea, out num);
                        if (inputarea == "")
                        {
                            ordertoedit.Area = ordertofind.Area;
                            break;
                        }
                        if (inputarea != "" && test && decimal.Parse(inputarea) > 0)
                        {
                            ordertoedit.Area = num;
                            break;
                        }
                    } while (true);

                    // confirm (y/n)
                    bool prompt = false;
                    string newgame = "";
                    while (prompt == false)
                    {
                        Console.Write("\nCommit 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")
                    {

                        var response1 = manager.EditOrder(ordertoedit, date, ordernumber); // the order before it's been fully populated.
                        var editedorder = response1.Data.Order; // the one we get back after we load all data.

                        Console.Clear();
                        Console.WriteLine("(SUMMARY OF NEWLY EDITED ORDER)");
                        Console.WriteLine("*****************");
                        Console.WriteLine("orderNumber  customerName  stateName  taxRate  productType  Area    CostPerSquareFoot LaborCostPerSquareFoot MaterialCost LaborCost Tax   Total");
                        const string formateditorder = "{0,1} {1,19} {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(formateditorder, editedorder.orderNumber,
                            editedorder.customerName, editedorder.stateName,
                            editedorder.taxRate, editedorder.productType,
                            editedorder.Area, editedorder.CostPerSquareFoot,
                            editedorder.LaborCostPerSquareFoot,
                            editedorder.MaterialCost, editedorder.LaborCost,
                            editedorder.Tax, editedorder.Total);
                        Console.WriteLine(line1);
                        Console.WriteLine();
                        Console.Write("Order has been edited. Press any key to continue...");
                        Console.ReadKey();
                    }
                    else // user types no. Revert back to old order information.
                    {
                        manager.EditOrder(ordertofind, date, ordernumber);
                        Console.Write("Edited changes cancelled. Press any key to continue...");
                        Console.ReadKey();
                    }
                }
            }
        }
예제 #6
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);
 }