Exemplo n.º 1
0
        public void Execute()
        {
            var prompts = new UserPrompts();
            var ops = new OrderOperations();
            EditOrderPrompts query;
            var response = new Response();
            var slip = new OrderSlip();
            bool tryAgain = false;

            do
            {
                tryAgain = false;
                slip = prompts.GetOrderInfoFromUser();
                response = ops.GetOrder(slip.OrderNumber, slip.Date);
                if (!response.Success)
                {
                    Console.WriteLine(response.Message);
                    tryAgain = prompts.PromptUserToTryAgain();
                }
                else
                {
                    query = new EditOrderPrompts(response.Order);
                    var queryResponse = query.EditOrder();

                    if (queryResponse.Updated)
                    {
                        ops.EditOrder(queryResponse.Order, slip.Date);
                    }

                    DisplayOrderInformation.DisplayEditOrderInfo(queryResponse.Order);
                }
            } while (tryAgain);
        }
        public static void DisplayRepoInfo(OrderSlip orderQuery)
        {
            Logger.Info("Display Order Repo Info", "DisplayOrderInformation.DisplayRepoInfo");

            var ops = new OrderOperations();
            var response = ops.GetAllOrders(orderQuery.Date);

            Console.Clear();
            if (response.Success)
            {
                foreach (var order in response.OrderList)
                {
                    Console.WriteLine("Order Number: {0}\n Customer Name: {1}\n State: {2}\n Tax Rate: {3:p}\n Product Type: {4}\n Area: {5}\n Cost per Square Foot: {6:c}\n Labor Cost Per Square Foot: {7:c}\n Material Cost: {8:c}\n Labor Cost: {9:c}\n Total Tax: {10:c}\n Total Cost: {11:c}",
                        order.OrderNumber, order.CustomerName, order.State.StateAbbreviation, order.TaxRate / 100,
                        order.ProductType.ProductType, order.Area, order.CostPerSquareFoot, order.LaborCostPerSquareFoot,
                        order.MaterialCost, order.LaborCost, order.Tax, order.Total);
                    Console.WriteLine();
                }

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

            Console.WriteLine("Press any key to return to Main menu...");
            Console.ReadKey();
        }
Exemplo n.º 3
0
 public Response()
 {
     Message = "";
     Order = new Order();
     Slip = new OrderSlip();
     OrderList = new List<Order>();
     State = new State();
     Product = new Product();
 }
Exemplo n.º 4
0
        public Response CreateOrder(OrderSlip slip)
        {
            Logger.Info("Create order called", "OrderOps - CreateOrder");

            var orderToCreate = new Order();

            orderToCreate.CustomerName = slip.CustomerName;
            orderToCreate.State = slip.State;
            orderToCreate.ProductType = slip.ProductType;
            orderToCreate.Area = slip.Area;

            orderToCreate = CalculateOrderTotals(orderToCreate, orderToCreate.State, orderToCreate.ProductType);

            _response.Order = orderToCreate;
            _response.Success = true;

            return _response;
        }
        public void CreateOrderTest(DateTime date, string CustomerName, string State, string ProductType, decimal Area, int orderIndex)
        {
            // arrange
            var slip = new OrderSlip();
            Response response = new Response();

            slip.CustomerName = CustomerName;
            slip.State.StateAbbreviation = State;
            slip.ProductType.ProductType = ProductType;
            slip.Area = Area;

            // act

            response = ops.CreateOrder(slip);
            response.Slip.Date = date;
            ops.WriteNewOrderToRepository(response);

            string order = ops.ToCSVForTesting(response.Order);

            // assert

            Assert.AreEqual(order, createdOrders[orderIndex]);
        }
Exemplo n.º 6
0
 public UserPrompts()
     : base()
 {
     _orderSlip = Response.Slip;
     _repositoryOperations = new RepositoryOperations();
 }
Exemplo n.º 7
0
        private void GetOrderNumberFromUser()
        {
            do
            {
                Console.Write("Enter an Order number: ");
                string orderNoInput = Console.ReadLine();

                Response = ValidateOrderNumber(orderNoInput);

                Console.WriteLine(Response.Message);

            } while (!Response.Success);

            _orderSlip = Response.Slip;
        }
Exemplo n.º 8
0
        private void GetOrderDateFromUser()
        {
            do
            {
                Console.Clear();
                Console.Write("Enter a date: ");
                string dateInput = Console.ReadLine();

                Response = ValidateDate(dateInput);

                Console.WriteLine(Response.Message);

            } while (!Response.Success);

            _orderSlip = Response.Slip;
        }
Exemplo n.º 9
0
        private void GetCustomerNameFromUser()
        {
            do
            {
                Console.Write("Enter Customer Name: ");
                string customerNameInput = Console.ReadLine();

                Response = ValidateCustomerName(customerNameInput);

                Console.WriteLine(Response.Message);

            } while (!Response.Success);

            _orderSlip = Response.Slip;
        }
Exemplo n.º 10
0
        private void GetAreaFromUser()
        {
            do
            {
                Console.Write("Enter area in square foot: ");
                string areaInput = Console.ReadLine().ToUpper();

                Response = ValidateArea(areaInput);

                Console.WriteLine(Response.Message);

            } while (!Response.Success);

            _orderSlip = Response.Slip;
        }