コード例 #1
0
        public void CanAddOrder()
        {
            CalculateTotals calculator = new CalculateTotals();
            OrderManager    manager    = new OrderManager(new OrderRepository(), new ProductRepository(), new TaxesRepository());
            Order           testOrder  = new Order()
            {
                OrderDate              = new DateTime(2020, 01, 01),
                CustomerName           = "Scrooge McDuck",
                State                  = "MN",
                TaxRate                = 2,
                ProductType            = "Tile",
                Area                   = 500,
                CostPerSquareFoot      = 1,
                LaborCostPerSquareFoot = 1
            };

            AddOrderResponse response = manager.addOrder(testOrder, testOrder.OrderDate);

            Assert.AreEqual("Scrooge McDuck", testOrder.CustomerName);
            Assert.AreEqual("MN", testOrder.State);
            Assert.AreEqual("Tile", testOrder.ProductType);
            Assert.AreEqual(500, testOrder.Area);

            //Make sure calculations are made correctly
            Assert.AreEqual(500, calculator.MaterialCost(testOrder));
            Assert.AreEqual(500, calculator.LaborCost(testOrder));
            Assert.AreEqual(20, calculator.Tax(testOrder));
            Assert.AreEqual(1020, calculator.Total(testOrder));
        }
コード例 #2
0
        public void CanAddOrder(string orderDate, int orderNumber, string customerName, string state, decimal taxRate, string product,
                                decimal area, decimal costPerFt, decimal laborPerFt, decimal matCost, decimal laborCost, decimal tax,
                                decimal total, bool expectedResult)

        {
            OrderManager manager  = OrderManagerFactory.Create();
            Order        newOrder = new Order();

            newOrder.OrderDate             = orderDate;
            newOrder.OrderNumber           = orderNumber;
            newOrder.CustomerName          = customerName;
            newOrder.State                 = state;
            newOrder.TaxRate               = taxRate;
            newOrder.ProductType           = product;
            newOrder.Area                  = area;
            newOrder.CostPerSquareFoot     = costPerFt;
            newOrder.LaborCostPerSqareFoot = laborPerFt;
            newOrder.MaterialCost          = matCost;
            newOrder.LaborCost             = laborCost;
            newOrder.Tax   = tax;
            newOrder.Total = total;

            AddOrderResponse response = manager.AddOrder(newOrder, orderDate);

            Assert.IsNotNull(response.NewOrder);
            Assert.IsTrue(response.Success);
            Assert.AreEqual(orderNumber, expectedResult);
        }
コード例 #3
0
        public void CanAddOrderTest(string customerName, string stateAbbrev, string material, decimal area, bool success) //tests the LoadOrderMethod
        {
            OrderManager     manager  = new OrderManager(new OrdersTestRepo(), new ProductTestRepo(), new TaxTestRepo());
            AddOrderResponse addOrder = manager.AddOrder(date, customerName, stateAbbrev, material, area, 0);

            Assert.AreEqual(addOrder.Success, success);
        }
コード例 #4
0
        private void AskToEditState()
        {
            StateManager     stateManager = StateManagerFactory.Create(); //calls state repo
            AddOrderResponse response     = new AddOrderResponse();

            Console.Clear();
            ConsoleIO.DisplaySingleOrder(_originalOrder);

            while (true)
            {
                Console.Write("Enter new state or just press enter to continue: ");
                string state = Console.ReadLine();

                if (state == "" || state == null)
                {
                    _taxState = stateManager.GetStateInfo(_originalOrder.State);
                    break;
                }
                else
                {
                    response = stateManager.ValidateState(state.ToLower());
                    if (response.Success == false)
                    {
                        Console.WriteLine("The state entered is not valid. Press any key to continue.");
                        continue;
                    }
                    else
                    {
                        _taxState = stateManager.GetStateInfo(state.ToLower());
                        break;
                    }
                }
            }
        }
コード例 #5
0
        private void AskToEditArea()
        {
            AccountManager   manager  = AccountManagerFactory.Create();
            AddOrderResponse response = new AddOrderResponse();

            Console.Clear();
            ConsoleIO.DisplaySingleOrder(_originalOrder);
            while (true)
            {
                Console.Write("Enter new area or just press enter to continue: ");
                string area = Console.ReadLine();

                if (area == "")
                {
                    _newArea = _originalOrder.Area.ToString();
                    break;
                }
                else
                {
                    response = manager.CheckArea(area);
                    if (response.Success == false)
                    {
                        Console.WriteLine("An error occurred with the area entered. Contact IT.");
                        Console.WriteLine("Press any key to continue.");
                        Console.ReadKey();
                        continue;
                    }
                    else
                    {
                        _newArea = area;
                        break;
                    }
                }
            }
        }
コード例 #6
0
        public AddOrderResponse AddOrder(Order order)
        {
            AddOrderResponse response    = new AddOrderResponse();
            List <Product>   productList = _productRepository.LoadAllProducts();
            List <Tax>       taxList     = _taxRepository.LoadAllTax();

            if (order.CustomerName == null)
            {
                response.Success = false;
                response.Message = $"{order.CustomerName} can not be blank.";
            }
            else if (order.Area < 100)
            {
                response.Success = false;
                response.Message = $"{order.Area} is not greater than the minimum 100 area.";
            }
            else if (productList.Where(product => product.ProductType == order.ProductType).ToList().Count == 0)
            {
                response.Success = false;
                response.Message = $"{order.ProductType} is not a valid product type.";
            }
            else if (taxList.Where(tax => tax.StateAbbreviation == order.State.ToUpper()).ToList().Count == 0)
            {
                response.Success = false;
                response.Message = $"{order.State} is not serviced by this company.";
            }
            else
            {
                _orderRepository.SaveOrder(order);
                response.Order   = order;
                response.Success = true;
            }
            return(response);
        }
コード例 #7
0
        public void CanAddOrderTest(DateTime orderDate, string customerName, string stateName, string productType,
                                    decimal Area, bool expectedResult)
        {
            IAddOrder addOrder;

            AddOrderRules addOrderRules = new AddOrderRules();

            addOrder = addOrderRules;

            Order order = new Order();

            orderDate = order.OrderDate;

            customerName = order.CustomerName;

            stateName = order.State;

            productType = order.ProductType;

            Area = order.Area;

            AddOrderResponse response = addOrder.AddOrder(order, orderDate, customerName, stateName, productType, Area);

            expectedResult = response.Success;

            Assert.AreEqual(expectedResult, response.Success);
        }
コード例 #8
0
        public AddOrderResponse GetProductInfo(ProductType type)
        {
            AddOrderResponse response = new AddOrderResponse();

            response.Order.Product = ProductCostsRepo.GetProductInfor(type);
            return(response);
        }
コード例 #9
0
ファイル: FlooringManager.cs プロジェクト: kjakoby/SGRepo
        //public AddOrderResponse AddOrder(string orderDate, string custName, string stateAbbrev, string prodType, decimal area)
        //{
        //    AddOrderResponse response = new AddOrderResponse();

        //    //response = AddOrder(response.Order, orderDate, custName, stateAbbrev, prodType, area);

        //    AddRule addOrderRule = new AddRule();

        //    response = addOrderRule.AddOrder(orderDate, custName, stateAbbrev, prodType, area);

        //    return response;
        //}

        public AddOrderResponse AddOrder(DateTime orderDate, string custName, string stateAbbrev, string prodType, decimal area, decimal taxRate,
                                         decimal cost, decimal labor, decimal materialCost, decimal laborCost, decimal tax, decimal total, Product prodChosen)
        {
            AddOrderResponse response = new AddOrderResponse();
            Order            order    = new Order();

            response.Order = order;
            //need to get number by next avail order number
            //response.Order.OrderNumber = 3;
            response.Order.OrderDate    = orderDate;
            response.Order.CustomerName = custName;
            response.Order.State        = stateAbbrev;
            response.Order.ProductType  = prodChosen.ProductType;
            response.Order.Area         = area;
            //tax is where response stateAbbrev == tax.StateAbbrev
            //prod is where response.ProductType == product.productType
            response.Order.TaxRate                = taxRate;
            response.Order.CostPerSquareFoot      = cost;
            response.Order.LaborCostPerSquareFoot = labor;
            response.Order.LaborCost              = laborCost;

            response.Order.MaterialCost = materialCost;
            //response.TaxRate = tax.TaxRate;
            response.Order.Tax   = tax;
            response.Order.Total = total;
            return(response);
        }
コード例 #10
0
        public AddOrderResponse ValidateState(string stateAbbreviation)
        {
            AddOrderResponse response = new AddOrderResponse();

            StateManager stateRepo = StateManagerFactory.Create();

            if (stateAbbreviation.Length != 2 || !stateAbbreviation.All(char.IsLetter))
            {
                response.Success = false;
                response.Message = "You have entered an invalid State format (must be 2-letter abbreviation).";
                return(response);
            }

            response.State = _stateRepository.GetState(stateAbbreviation.ToLower());

            if (response.State == null)
            {
                response.Success = false;
                response.Message = $"We do not sell to {stateAbbreviation}. Please enter state:";
            }

            else
            {
                response.Success = true;
            }

            return(response);
        }
コード例 #11
0
        public AddOrderResponse StateTaxCheck(States state)
        {
            AddOrderResponse response = new AddOrderResponse();

            response.Order.TaxRate = StateTaxRepo.GetStateTax(state);
            return(response);
        }
コード例 #12
0
        public AddOrderResponse CheckOrderDate(string orderDate)
        {
            AddOrderResponse response = new AddOrderResponse();

            //check if blank
            if (orderDate == "")
            {
                response.Success = false;
                response.Message = "Error: The Order Date cannot be blank.";
                return(response);
            }

            //Check if date is in correct format
            if (orderDate.Length != 8 || orderDate.All(char.IsLetter))
            {
                response.Success = false;
                response.Message = "Error: The Order Date must be in the format MMddyyyy.";
                return(response);
            }

            // Checking if date is in future
            CultureInfo provider = CultureInfo.InvariantCulture;

            if (DateTime.ParseExact(orderDate, "MMddyyyy", provider) <= DateTime.Today)
            {
                response.Success = false;
                response.Message = "Order date must be in the future.";
                return(response);
            }

            response.Success = true;
            return(response);
        }
コード例 #13
0
        public void AddOrder(int OrderNumber, string name, string state, string ProductType, decimal Area, bool expectedResults)
        {
            //should output to 1 for true but keeps throwing exception because not bool

            OrderTestRepository repo = new OrderTestRepository();

            Order Order = new Order();

            Order.OrderNumber  = OrderNumber;
            Order.CustomerName = name;
            Order.State        = state;
            Order.Area         = Area;
            Order.ProductType  = ProductType;


            AddOrderResponse response = new AddOrderResponse();

            response.Order = repo.SaveOrder(Order, DateTime.Today);
            if (response.Order.Area == 1)
            {
                response.Sucess = true;
            }
            var response2 = repo.SaveOrder(response.Order, DateTime.Today);



            Assert.AreEqual(expectedResults, response.Sucess);
        }
コード例 #14
0
        [TestCase("", "OH", 0, "Tile", 100.00, 0, 0, 0, 0, 0, 0, false)]          // invalid CustomerName
        public void CanAddOrderToOrderList(string customerName, string state, decimal taxRate, string productType, decimal area, decimal costPerSquareFoot, decimal laborCostPerSquareFoot, decimal materialCost, decimal laborCost, decimal tax, decimal total, bool expectedResult)
        {
            OrderManager manager = OrderManagerFactory.Create();

            DateTime          date        = new DateTime(2021, 01, 01);
            AllOrdersResponse allResponse = manager.RetrieveAllOrders(new DateTime(2021, 01, 01));
            List <Order>      orderList   = allResponse.Orders;

            Order newOrder = new Order();

            newOrder.OrderDate              = new DateTime(2021, 01, 01);
            newOrder.OrderNumber            = orderList.Max(order => order.OrderNumber) + 1;
            newOrder.CustomerName           = customerName;
            newOrder.State                  = state;
            newOrder.TaxRate                = 0;
            newOrder.ProductType            = productType;
            newOrder.Area                   = area;
            newOrder.CostPerSquareFoot      = costPerSquareFoot;
            newOrder.LaborCostPerSquareFoot = laborCostPerSquareFoot;
            newOrder.MaterialCost           = materialCost;
            newOrder.LaborCost              = laborCost;
            newOrder.Tax   = tax;
            newOrder.Total = total;

            AddOrderResponse       response  = new AddOrderResponse();
            CalculateOrderResponse response2 = manager.CalculateOrder(newOrder);

            if (response2.Success)
            {
                response = manager.AddOrder(response2.Order);
            }

            Assert.AreEqual(expectedResult, response.Success);
        }
コード例 #15
0
        public void OrderAddTest(string customerName, string state, string productType, decimal area, bool expectedResult)
        {
            int originalOrderNumber = 0;

            DateTime date = DateTime.Today;

            date = date.AddYears(1);

            Order order = new Order()
            {
                CustomerName = customerName, State = state, ProductType = productType, Area = area
            };

            order.OrderDate = date;

            OrderManager manager = OrderManagerFactory.Create();

            AddOrderResponse response = manager.OrderAdd(order.OrderDate, order, originalOrderNumber);

            var actual = response.Success;

            Assert.AreEqual(expectedResult, actual);

            RemoveOrderResponse response2 = manager.OrderRemove(order.OrderDate, originalOrderNumber, order);
        }
コード例 #16
0
        public void CanDeleteOrder(int orderNumber, string date, bool expected)
        {
            DateTime orderDate = DateTime.Parse(date);
            Order    _order    = new Order
            {
                OrderDate              = DateTime.Parse("08/07/2020"),
                OrderNumber            = 100,
                CustomerName           = "Chuck Testa",
                State                  = "OH",
                TaxRate                = 6.25m,
                ProductType            = "Carpet",
                Area                   = 100.5m,
                CostPerSquareFoot      = 2.25m,
                LaborCostPerSquareFoot = 2.25m,
            };

            OrderManager     orderManager     = new OrderManager(orderRepo);
            AddOrderResponse addOrderResponse = orderManager.AddOrder(_order);


            OrderLookupResponse orderLookup = orderManager.LookupOrder(orderNumber, orderDate);

            if (orderLookup.Success)
            {
                DeleteOrderResponse deleteOrderResponse = orderManager.DeleteOrder(orderLookup.Order);
                Assert.AreEqual(expected, deleteOrderResponse.Success);
            }
            else
            {
                Assert.AreEqual(expected, orderLookup.Success);
            }
        }
コード例 #17
0
        public AddOrderResponse AddOrder(Orders order)
        {
            DisplayOrderResponse orderResponse = new DisplayOrderResponse();

            orderResponse.orders = _orderRepository.DisplayOrder();

            AddOrderResponse addResponse = new AddOrderResponse();

            addResponse.orders = order;
            if (orderResponse.orders != null && orderResponse.orders.Where(c => c.OrderNumber == order.OrderNumber).Count() > 0)
            {
                addResponse.Success = false;
                addResponse.Message = $"{order.OrderNumber} is already existed.";
                return(addResponse);
            }

            if (!_orderRepository.AddOrder(order))
            {
                addResponse.Success = false;
                addResponse.Message = $"Cannot add {order.OrderNumber}.";
            }
            else
            {
                addResponse.Success = true;
                addResponse.Message = $"Successfully added order {order.OrderNumber}.";
            }
            return(addResponse);
        }
コード例 #18
0
        public AddOrderResponse AddOrder(Order order, DateTime orderDate, string customerName, string stateName, string productType, decimal Area)
        {
            List <Order> Orders = ProductionRepository.GetOrders();

            List <Products> Products = ProductionRepository.GetProducts();

            List <Taxes> Taxes = ProductionRepository.GetTaxes();

            AddOrderResponse response = new AddOrderResponse();

            if (orderDate <= DateTime.Today)
            {
                response.Success = false;
                response.Message = "Error: Order Date Must Be in the Future.";
                return(response);
            }
            if (string.IsNullOrEmpty(customerName) == true)
            {
                response.Success = false;
                response.Message = "Error: Customer Name Cannot Be Blank.";
                return(response);
            }
            if (!Taxes.Any(t => t.StateAbbreviation == stateName))
            {
                response.Success = false;
                response.Message = "Error: Incorrect State Code - Please Check Records and Re-Enter.";
                return(response);
            }
            if (!Products.Any(p => p.ProductType.ToUpper() == productType.ToUpper()))
            {
                response.Success = false;
                response.Message = "Error: That is Not a Current Product in Our System.";
                return(response);
            }

            if (Area <= 0)
            {
                response.Success = false;
                response.Message = "Error: Area Must be a Positive Number.";
                return(response);
            }
            else
            {
                response.OrderDate = orderDate;

                response.CustomerName = customerName;

                response.StateName = stateName;

                response.ProductType = productType;

                response.Area = Area;

                response.Success = true;

                response.Message = "Order Added Successfully!";

                return(response);
            }
        }
コード例 #19
0
        public static void Execute()
        {
            Console.Clear();
            OrderManager orderManager = OrderManagerFactory.Create();

            string date = ConsoleIO.GetDate();

            string name = ConsoleIO.GetName();

            string state = ConsoleIO.GetState();

            string productType = ConsoleIO.GetProductType();

            string area = ConsoleIO.GetArea();

            AddOrderResponse response = orderManager.AddOrder(date, name, state, productType, area);

            if (response.Success)
            {
                Console.WriteLine(response.Message);
            }
            else
            {
                Console.WriteLine(response.Message);
            }

            Console.WriteLine("Press any key to continue");
            Console.ReadKey();
        }
コード例 #20
0
        public void AddOrders()
        {
            List <Order> pendingOrders = OrderService.GetOrders(StatusID: (int)Beasts.Model.Status.Pending).ToList();

            foreach (Order order in pendingOrders)
            {
                try
                {
                    if (PayPal.CheckSale(order.PaypalSaleID))
                    {
                        AddOrderRequest addOrderRequest = Mapper.Map <AddOrderRequest>(order);

                        AddOrderResponse addOrderResponse = client.AddOrder(addOrderRequest);

                        if (addOrderResponse.Result == 1 && addOrderResponse.Order != null)
                        {
                            order.PrintAuraID = addOrderResponse.Order.OrderId;
                            order.Status      = Beasts.Model.Status.Processing;
                            OrderService.UpdateOrder(order);
                        }
                    }
                }
                catch (Exception ex)
                {
                    ExceptionService.CreateException(ex);
                }
            }
        }
コード例 #21
0
        public void OrderManagerAddOrderTest(DateTime date, string customerName, string state, string productType, decimal area, bool expectedResult, int expectedCount)

        {
            TestOrderRepository   testOrderRepo   = new TestOrderRepository();
            TestProductRepository testProductRepo = new TestProductRepository();
            TestTaxRepository     testTaxRepo     = new TestTaxRepository();
            OrderManager          addOrderRule    = new OrderManager(testOrderRepo, testProductRepo, testTaxRepo);
            AddOrderResponse      response        = addOrderRule.BuildNewOrder(date, customerName, state, productType, area);

            //Order order = new Order();

            //order.Date = date;
            //order.OrderNumber = orderNumber;
            //order.CustomerName = customerName;
            //order.State = state;
            //order.TaxRate = taxRate;
            //order.ProductType = productType;
            //order.Area = area;
            //order.CostPerSquareFoot = costPerSqFt;
            //order.LaborCostPerSquareFoot = laborCostPerSqFt;

            Assert.AreEqual(expectedResult, response.Success);
            if (response.Success)
            {
                testOrderRepo.CommitThisOrder(response.Order);

                Assert.AreEqual(expectedCount, testOrderRepo.GetAllOrdersForDate(date).Count);
            }
        }
コード例 #22
0
        public void Exicute()
        {
            Console.Clear();
            AddOrderResponse addOrderResponse = new AddOrderResponse();
            OrderManager     orderManager     = OrderManagerFactory.Create();

            Console.WriteLine("Add order");
            Console.WriteLine("===============================");
            addOrderResponse = SubLogic.MakeValidOrder();

            if (addOrderResponse.Success)
            {
                Console.Clear();
                bool areYouSure = SubLogic.ConfirmOrderToAdd(addOrderResponse.OrderToAdd);
                if (areYouSure == true)
                {
                    addOrderResponse = orderManager.AddOrder(addOrderResponse.OrderToAdd);
                    Console.WriteLine(addOrderResponse.Message);
                    Console.WriteLine("press any key to continue");
                    Console.ReadKey();
                }
            }
            else
            {
                Console.WriteLine(addOrderResponse.Message);
                Console.WriteLine("press any key to continue");
                Console.ReadKey();
            }
        }
コード例 #23
0
        private void GetArea()
        {
            Console.Clear();
            while (true)
            {
                Console.Write("\nEnter the number of square feet for new order: ");
                //decimal area = decimal.Parse(Console.ReadLine());
                decimal returnDecimal;
                string  area = Console.ReadLine();
                decimal.TryParse(area, out returnDecimal);

                response = manager.CheckArea(returnDecimal.ToString());

                if (response.Success == false)
                {
                    Console.WriteLine(response.Message);
                    continue;
                }
                else
                {
                    _area = returnDecimal;
                    break;
                }
            }
        }
コード例 #24
0
        public void CanAddOrder()
        {
            AccountManager   manager  = AccountManagerFactory.Create();
            AddOrderResponse response = new AddOrderResponse();

            Orders order = new Orders()
            {
                OrderDate              = "07012017",
                OrderNumber            = 1,
                CustomerName           = "Jane Doe",
                State                  = "PA",
                TaxRate                = 6.75M,
                ProductType            = "Laminate",
                Area                   = 230.00M,
                CostPerSquareFoot      = 1.75M,
                LaborCostPerSquareFoot = 2.10M,
                MaterialCost           = 402.50M,
                LaborCost              = 483M,
                Tax   = 59.77M,
                Total = 945.27M
            };

            response = manager.AddOrderResponse(order);

            Assert.IsTrue(response.Success);
        }
コード例 #25
0
        public AddOrderResponse CheckState(string stateAbbreviation)
        {
            AddOrderResponse response = new AddOrderResponse();

            IStateRepository stateRepo = RepoFactory.CreateStateRepo();

            List <State> states = stateRepo.GetListOfStates();

            if (stateAbbreviation.Length != 2 || !stateAbbreviation.All(char.IsLetter))
            {
                response.Success = false;
                response.Message = "You have entered an invalid State format (must be 2-letter abbreviation).";
                return(response);
            }

            foreach (var state in states)
            {
                if (state.StateAbbreviation == stateAbbreviation)
                {
                    response.Success = true;
                    return(response);
                }
            }

            response.Success = false;
            response.Message = $"We do not sell products in the state of {stateAbbreviation}.";
            return(response);
        }
コード例 #26
0
        private void GetProductType()
        {
            while (true)
            {
                Console.Clear();
                response.ProductsList = productManager.GetProductsToDisplay();

                ConsoleIO.DisplayProductsAvailable(response.ProductsList);

                Console.Write("\nSelect a product to order from the Product List above: ");
                string productType = Console.ReadLine();
                response = productManager.CheckProduct(productType.ToLower());

                if (response.Success == false)
                {
                    Console.WriteLine(response.Message);
                    Console.WriteLine("Press any key to continue: ");
                    Console.ReadLine();
                    continue;
                }
                else
                {
                    _productType = productManager.GetProductInfo(productType.ToLower());
                    break;
                }
            }
        }
コード例 #27
0
        public AddOrderResponse CheckDate(string date)
        {
            AddOrderResponse response = new AddOrderResponse();

            // date format
            if (date.Length != 8 || !date.All(char.IsDigit))
            {
                response.Success = false;
                response.Message = "Please use correct order date format (MMDDYYYY)";
                return(response);
            }


            // date in future?

            CultureInfo provider = CultureInfo.InvariantCulture;

            if (DateTime.ParseExact(date, "MMddyyyy", provider) <= DateTime.Today)
            {
                response.Success = false;
                response.Message = "Specific order date must be in the future.";
                return(response);
            }

            response.Success = true;
            return(response);
        }
コード例 #28
0
        public AddOrderResponse AddOrder(Order newOrder, string date)
        {
            AddOrderResponse response = new AddOrderResponse();

            response.NewOrder = new Order();
            var orders = _orderRepository.ReadOrders(date);             //returns list of all orders from that orders date

            if (orders == null)
            {
                response.Success = false;
                response.Message = "Unknown error. Please contact IT.";
            }

            int orderNumTotal = 0;

            if (orders.Count > 0)
            {
                orderNumTotal = orders.Select(o => o.OrderNumber).Max(); //returns the max number of orders. ex/ if 3 orders, it'll return the # 3
            }
            newOrder.OrderNumber = orderNumTotal + 1;                    //adds 1 to the last order number to create new order number in sequence
            orders.Add(newOrder);                                        //adds new order to orders list
            _orderRepository.OverwriteFile(orders, date);                //sends orders to be exported to a file
            response.Success   = true;
            response.NewOrder  = newOrder;                               //returns the new order info
            response.OrderDate = date;                                   //returns original order date (so that won't change)

            return(response);
        }
コード例 #29
0
        public void CanAddOrder(DateTime orderDate, string customerName, string state, string productType, decimal area, bool expected)
        {
            OrderManager orderManager = OrderManagerFactory.create(orderDate);

            TaxManager         taxManager  = TaxManagerFactory.create();
            DisplayTaxResponse taxResponse = taxManager.DisplayTaxResponse(state);

            ProductManager         productManager  = ProductManagerFactory.create();
            DisplayProductResponse productResponse = productManager.DisplayProductResponse(productType);

            Orders order = new Orders()
            {
                Area = area,
                CostPerSquareFoot      = productResponse.Products.CostPerSquareFoot,
                CustomerName           = customerName,
                LaborCostPerSquareFoot = productResponse.Products.LaborCostPerSquareFoot,
                OrderNumber            = orderManager.GenerateOrderNumber(),
                ProductType            = productResponse.Products.ProductType,
                State   = taxResponse.Tax.StateAbbreviation,
                TaxRate = taxResponse.Tax.TaxRate,
            };

            AddOrderResponse orderResponse = orderManager.AddOrder(order);

            Assert.AreEqual(orderResponse.Success, expected);
        }
コード例 #30
0
        public void Execute()
        {
            IUserIO userIO = new UserIO();

            userIO.Clear();
            FlooringManager manager = FlooringFactoryManager.Create();
            Order           order   = new Order();

            userIO.WriteLine("CREATE NEW ORDER: ");
            userIO.WriteLine("");
            userIO.WriteLine(new string('=', 60));
            userIO.WriteLine("");
            order.OrderDate    = HelperMethods.GetDateTime("Please enter the date of order: ");
            order.CustomerName = HelperMethods.GetCustomerName("Please enter the customers name: ");
            order.State        = HelperMethods.GetStateTax(TaxRepository.GetTaxes());
            order.ProductType  = HelperMethods.GetProductInformation(ProductRepository.GetProducts());
            order.Area         = HelperMethods.GetDecimalFromString("Enter the Area: ");

            order = manager.CalculateOrder(order);
            userIO.DisplayOrder(order);

            if (HelperMethods.GetYesNoAnswerFromUser("Would you like to create this order?"))
            {
                userIO.WriteLine("Order has succesfully been created.");
                AddOrderResponse response = manager.AddOrder(order);
            }
            else
            {
                userIO.WriteLine("Order was not created.");
            }
        }
コード例 #31
0
        public AddOrderResponse AddProduct(Order order)
        {
            var response = new AddOrderResponse();
            response.Order = order;

            if (!_productRepository.IsAllowableProduct(order.Product.ProductType))
            {
                response.Success = false;
                response.Status = AddOrderStatus.InvalidProductType;

                return response;
            }

            response.Success = true;
            response.Status = AddOrderStatus.Ok;

            return response;
        }
コード例 #32
0
        public AddOrderResponse AddState(Order order)
        {
            var response = new AddOrderResponse();
            response.Order = order;

            if (!_taxRepository.IsAllowableState(order.StateTax.StateAbbreviation))
            {
                response.Success = false;
                response.Status = AddOrderStatus.InvalidTaxRate;

                return response;
            }

            response.Success = true;
            response.Status = AddOrderStatus.Ok;

            return response;
        }