public void EditOrderTest()
 {
     // arrange
     var date = "09222015";
     var order1 = new Order();
     var manager = new OrderManager();
     order1.orderNumber = 6;
     order1.customerName = "Wise";
     order1.stateName = "OH";
     order1.taxRate = 6.25M;
     order1.productType = "Wood";
     order1.Area = 100.00M;
     order1.CostPerSquareFoot = 5.15M;
     order1.LaborCostPerSquareFoot = 4.75M;
     order1.MaterialCost = 515.00M;
     order1.LaborCost = 475.00M;
     order1.Tax = 61.88M;
     order1.Total = 1051.88M;
     // act
     manager.AddOrder(order1, date);
     order1.customerName = "Dave";
     var response = manager.EditOrder(order1, date, 6);
     var newname = response.Data.Order.customerName;
     // assert
     Assert.AreNotEqual(newname, "Wise");
 }
        public void AddOrderTestNewFile()
        {
            string mode = "File";
            string productPath = @"DataFiles\Orders\";
            var orderManager = new OrderManager(mode, productPath);

            Order order = new Order()
            {
                OrderNumber = 1,
                CustomerName = "Ringo",
                State = "OH",
                TaxRate = 0.0625m,
                ProductType = "Wood",
                Area = 100m,
                CostPerSqFt = 5.15m,
                LaborCostPerSqFt = 4.75m,
                TotalMaterialCost = 515m,
                TotalLaborCost = 475m,
                TotalTax = 61.88m,
                Total = 1051.88m
            };

            var result = orderManager.AddOrder(order,"06012013");

            Assert.AreEqual(result.Data.Count, 1);
            Assert.IsTrue(result.Success);
            Assert.AreEqual(result.Data[0].CustomerName, "Ringo");
        }
 public void AddOrderTest()
 {
     // arrange
     var manager = new OrderManager();
     // act
     var order1 = new Order();
     order1.orderNumber = 1;
     order1.customerName = "Wise";
     order1.stateName = "OH";
     order1.taxRate = 6.25M;
     order1.productType = "Wood";
     order1.Area = 100.00M;
     order1.CostPerSquareFoot = 5.15M;
     order1.LaborCostPerSquareFoot = 4.75M;
     order1.MaterialCost = 515.00M;
     order1.LaborCost = 475.00M;
     order1.Tax = 61.88M;
     order1.Total = 1051.88M;
     string num = "09222015";
     var response = manager.AddOrder(order1, num);
     var count = response.Data.Orders.Count;
     // assert
     Assert.AreEqual(count, 3);
 }
        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();
            }
        }
        public void Execute()
        {
            var orderManager = new OrderManager(Program.Mode, Program.OrderPath);
            Console.Clear();
            //var name = getCustomerName();
            var _name = _helper.ValidCustomerName(getCustomerName());
            var _product = _helper.validProductRepo(getProductName());
            var _state = _helper.validStateRepo(getStateAbbrev());
            var _area = _helper.validArea(getArea());
            decimal _taxRate = _stateManager.getTaxRate(_state);
            decimal _laborCostPerSqFt = _productManager.GetLaborCostPerSqFt(_product);
            decimal _costPerSqFt = _productManager.GetCostPerSqFt(_product);
            decimal _totalLaborCost = orderManager.TotalLaborCostCal(_area, _laborCostPerSqFt);
            decimal _totalMaterialCost = orderManager.TotalMaterialCostCal(_area, _costPerSqFt);
            decimal _totalTax = orderManager.TotalTaxCal(_taxRate, _totalMaterialCost, _totalLaborCost);
            decimal _total = orderManager.TotalCal(_taxRate, _totalMaterialCost, _totalLaborCost);

            var newOrder = new List<Order>()
            { new Order()
                {
                    CustomerName = _name,
                    ProductType = _product,
                    State = _state,
                    TaxRate = _taxRate,
                    Area = _area,
                    LaborCostPerSqFt = _laborCostPerSqFt,
                    CostPerSqFt = _costPerSqFt,
                    TotalMaterialCost = _totalMaterialCost,
                    TotalLaborCost = _totalLaborCost,
                    TotalTax = _totalTax,
                    Total = _total
                 }
            };
            Console.Clear();
            Console.WriteLine("Here is your new order...");

            HelperMethod.displayOrders(newOrder);

            do
            {
                Console.WriteLine("Commit new order? Y/N");
                var commit = Console.ReadLine().ToUpper();
                if (commit == "Y" || commit == "YES")
                {
                    var result = orderManager.AddOrder(newOrder[0], _currentDate);

                    if (result.Success)
                    {
                        Console.WriteLine("You order is now added!");
                        HelperMethod.displayOrders(result.Data);
                        Console.WriteLine("Press any key to continue...");
                        Console.ReadKey();
                        break;
                    }
                    else
                    {
                        Console.WriteLine(result.Message);
                        Console.WriteLine("Press any key to continue...");
                        Console.ReadKey();
                        break;
                    }
                }
                else if (commit == "N" || commit == "NO")
                    break;
                Console.WriteLine("Your input is invalid. Press any key to continue...");
                Console.ReadKey();
            } while (true);
        }