public void Execute()
        {
            IUserIO userIO = new UserIO();
            DisplayOrderResponse response = new DisplayOrderResponse();
            FlooringManager      manager  = FlooringFactoryManager.Create();

            userIO.Clear();
            userIO.WriteLine("DISPLAY ORDER: ");
            userIO.WriteLine("");
            userIO.WriteLine(new string('=', 60));
            userIO.WriteLine("");
            List <Order> orders = manager.GetOrdersByDate(HelperMethods.GetDateTime("Enter an order date: "));

            if (orders == null || orders.Count == 0)
            {
                response.Success = false;
                response.Message = ("No order exists with that date.");
            }
            else
            {
                response.Success = true;
            }
            if (response.Success)
            {
                userIO.DisplayOrders(orders);
            }
            else
            {
                userIO.WriteLine("An error has occured: ");
                userIO.WriteLine(response.Message);
            }
            userIO.WriteLine("Press any key to continue.");
            userIO.ReadKey();
        }
        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.");
            }
        }
Пример #3
0
        public void Execute()
        {
            IUserIO userIO = new UserIO();

            userIO.Clear();
            FlooringManager manager = FlooringFactoryManager.Create();

            userIO.WriteLine("DELETE ORDER:");
            userIO.WriteLine("");
            userIO.WriteLine(new string('=', 60));
            userIO.WriteLine("");
            DateTime          dateTime    = HelperMethods.GetDateTime("Enter the order date: ");
            int               OrderNumber = HelperMethods.GetIntFromUser("Enter the order number: ");
            EditOrderResponse response    = new EditOrderResponse();
            Order             order       = manager.GetOrderByOrderNumber(dateTime, OrderNumber);

            if (order == null)
            {
                response.Success = false;
                response.Message = "No orders exist with this date.";
            }
            else
            {
                userIO.DisplayOrder(order);
                if (HelperMethods.GetYesNoAnswerFromUser("Would you like to delete this order?"))
                {
                    manager.DeleteOrder(order);
                    response.Success = true;
                    response.Message = "Order successfully deleted.";
                }
            }
        }
        public void Execute()
        {
            IUserIO userIO = new UserIO();

            userIO.Clear();
            FlooringManager manager = FlooringFactoryManager.Create();

            userIO.WriteLine("EDIT ORDER:");
            userIO.WriteLine("");
            userIO.WriteLine(new string('=', 60));
            userIO.WriteLine("");
            DateTime          dateTime    = HelperMethods.GetDateTime("Enter the order date: ");
            int               OrderNumber = HelperMethods.GetIntFromUser("Enter the order number: ");
            EditOrderResponse response    = new EditOrderResponse();
            Order             oldOrder    = manager.GetOrderByOrderNumber(dateTime, OrderNumber);
            Order             order       = oldOrder;

            if (oldOrder == null)
            {
                response.Success = false;
                response.Message = "No orders exist with this date.";
            }
            else
            {
                order.CustomerName = HelperMethods.GetCustomerName($"Previous Name: {oldOrder.CustomerName}\n Please enter the customers name: ", oldOrder.CustomerName);
                Console.WriteLine($"Previous State: {oldOrder.State}");
                order.State = HelperMethods.GetStateTax(TaxRepository.GetTaxes(), oldOrder.State);
                Console.WriteLine($"Previous Product: {oldOrder.ProductType}");
                order.ProductType = HelperMethods.GetProductInformation(ProductRepository.GetProducts());
                order.Area        = HelperMethods.GetDecimalFromString($"Previous Area: {oldOrder.Area}\n Enter the Area: ", oldOrder.Area);
                userIO.DisplayOrder(order);
                if (HelperMethods.GetYesNoAnswerFromUser("Would you like to create this order?"))
                {
                    manager.DeleteOrder(oldOrder);
                    manager.AddOrder(order);
                    response.Success = true;
                    response.Message = "Order successfully added.";
                }
            }
        }