Beispiel #1
0
        public void GetTaxFail()
        {
            IStateRepo  repo = new TestTaxRepo();
            TaxMgr      tm   = new TaxMgr(repo);
            TaxResponse resp = tm.GetTaxes("OHO");

            Assert.AreEqual(false, resp.Success);
        }
Beispiel #2
0
        public void GetTax()
        {
            IStateRepo  repo = new TestTaxRepo();
            TaxMgr      tm   = new TaxMgr(repo);
            TaxResponse resp = tm.GetTaxes("OH");
            StateTax    tax  = resp.StateTax;

            Assert.IsNotNull(tax);
        }
Beispiel #3
0
        public void Start()
        {
            OrderMgr orderManager = Factory.GetOrderRepo();

            //1. Customer Name
            Console.WriteLine("Please enter customer's name: ");
            string custName = Console.ReadLine();

            while (custName == "")
            {
                Console.WriteLine("Please input a name: ");
                custName = Console.ReadLine();
            }
            Utility  ut   = new Utility();
            DateTime date = ut.inputDate();

            //2. State info
            Console.WriteLine("Please enter state: ");
            string stateAbb = Console.ReadLine().ToUpper();

            while (stateAbb.Length != 2)
            {
                Console.WriteLine("Please input a 2 letter state abbreviation: ");
                stateAbb = Console.ReadLine().ToUpper();
            }

            // TaxResponse tResp = taxManager.GetTaxes(stateAbb);
            TaxMgr      Tmgr  = Factory.GetTaxRepo();
            TaxResponse tResp = Tmgr.GetTaxes(stateAbb);

            if (!tResp.Success)
            {
                orderManager.AddToError(tResp.Message);
                Console.WriteLine(tResp.Message);
                Console.ReadKey();
                return;
            }

            StateTax newTax = tResp.StateTax;

            //3. Product ordered:
            Console.WriteLine("Input the product ordered: ");
            string productType = Console.ReadLine();

            while (productType == "")
            {
                Console.WriteLine("Please input a product type: ");
                productType = Console.ReadLine();
            }

            ProductMgr      productManager = Factory.GetProdRepo();
            ProductResponse pResp          = productManager.GetProduct(productType);
            Product         newProd        = pResp.Product;

            if (!pResp.Success)
            {
                orderManager.AddToError(pResp.Message);
                Console.WriteLine(pResp.Message);
                Console.ReadKey();
                return;
            }


            //4. Area ordered:
            Console.WriteLine("Please input the area ordered: ");
            decimal area;
            string  userArea = Console.ReadLine();

            while (!decimal.TryParse(userArea, out area) || area <= 0)
            {
                Console.WriteLine("Invalid input. Please re-try. ");
                userArea = Console.ReadLine();
            }

            //Display the order
            Console.WriteLine("\nCustomer name: " + custName);
            Console.WriteLine("Date: " + date);
            Console.WriteLine("State: " + stateAbb);
            Console.WriteLine("Product: " + productType);
            Console.WriteLine("Area: " + userArea);
            Console.WriteLine("Tax: ");
            Console.WriteLine("Confirm to save the information (Y/N)?");
            string confirmation = Console.ReadLine().ToUpper();

            while (confirmation != "Y" && confirmation != "N")
            {
                Console.WriteLine("Invalid input. Please re-try: ");
                confirmation = Console.ReadLine();
            }
            if (confirmation == "Y")
            {
                Order newOrder = new Order(custName, newProd, newTax, area, date);
                orderManager.AddOrder(newOrder);
            }
        }
Beispiel #4
0
        public void Start()
        {
            OrderMgr orderManager = Factory.GetOrderRepo();

            Utility       ut       = new Utility();
            DateTime      dt       = ut.inputDate();
            int           orderNum = ut.InputOrderNumber();
            OrderResponse oResp    = orderManager.EditOrder(dt, orderNum);

            if (!oResp.Success)
            {
                Console.WriteLine(oResp.Message);
                Console.ReadKey();
                return;
            }

            Order edit = oResp.Order;

            Console.WriteLine("Edit customer name or hit Enter to continue...");
            string userInput = Console.ReadLine();
            string newName;

            if (userInput == "")
            {
                newName = edit.CustName;
            }
            else
            {
                newName = userInput;
            }

            Console.WriteLine("Edit order date or hit Enter to continue...");
            DateTime newDate;
            string   userDate = Console.ReadLine();

            if (userDate == "")
            {
                newDate = edit.Date;
            }
            else
            {
                while (!DateTime.TryParse(userDate, out newDate))
                {
                    Console.WriteLine("Incorrect format. Please input a date (MM/DD/YYYY):");
                    userDate = Console.ReadLine();
                }
            }

            Console.WriteLine("Edit State or hit Enter to continue...");
            userInput = Console.ReadLine();
            StateTax newState;
            TaxMgr   taxManager = Factory.GetTaxRepo();

            if (userInput == "")
            {
                newState = edit.STax;
            }
            else
            {
                while (userInput.Length != 2)
                {
                    Console.WriteLine("Please enter a 2-letter state abbreviation...");
                    userInput = Console.ReadLine();
                }
                TaxResponse taxResponse = taxManager.GetTaxes(userInput);
                if (!taxResponse.Success)
                {
                    orderManager.AddToError(taxResponse.Message);
                    Console.WriteLine(taxResponse.Message);
                    Console.ReadKey();
                    return;
                }
                newState = taxResponse.StateTax;
            }

            Console.WriteLine("Edit product or hit Enter to continue...");
            userInput = Console.ReadLine();
            Product    newProd;
            ProductMgr productManager = Factory.GetProdRepo();

            if (userInput == "")
            {
                newProd = edit.Product;
            }
            else
            {
                ProductResponse pResp = productManager.GetProduct(userInput);
                if (!pResp.Success)
                {
                    orderManager.AddToError(pResp.Message);
                    Console.WriteLine(pResp.Message);
                    Console.ReadKey();
                    return;
                }
                newProd = pResp.Product;
            }

            Console.WriteLine("Edit area or hit enter to continue...");
            userInput = Console.ReadLine();
            decimal newArea;

            if (userInput == "")
            {
                newArea = edit.Area;
            }
            else
            {
                while (!decimal.TryParse(userInput, out newArea) || newArea <= 0)
                {
                    Console.WriteLine("Invalid input.  Please re-try.");
                    userInput = Console.ReadLine();
                }
            }

            Order newOrder = new Order(
                newName,
                newProd,
                newState,
                newArea,
                newDate
                );

            newOrder.OrderNum = orderNum;
            orderManager.DeleteOrder(dt, orderNum);
            orderManager.AddOrder(newOrder);
        }