Exemple #1
0
        public void Execute()
        {
            //Console.Clear();
            //Console.WriteLine("You are now in the Display All Orders by Date section");
            //Console.ReadKey();
            ConsoleIO.Header("\t~All of Date's Orders~");

            DateTime orderDate = ConsoleIO.DateLookupPrompt();

            //get date to search by then out in .create(...)
            FlooringManager manager = FlooringManagerFactory.Create(orderDate);

            ConsoleIO.Header("\t~All of Date's Orders~");
            Dictionary <int, Order> orderDictionary = manager.GetAllOrders(orderDate);

            if (manager.orderRepository.FileExists())
            {
                if (manager.orderRepository.LastOrder() == true)
                {
                    ConsoleIO.DisplayAllOrders(orderDictionary, true, true, orderDate);
                }
                else
                {
                    ConsoleIO.DisplayAllOrders(orderDictionary, true, false, orderDate);
                }
            }


            ConsoleIO.KeyToContinue();
            Console.ReadKey();
        }
Exemple #2
0
        public void CanLoadOrderTestData()
        {
            DateTime        orderDate = DateTime.Now;
            FlooringManager manager   = FlooringManagerFactory.Create(orderDate);

            DisplaySingleResponse response = manager.LookupOrder(1, (DateTime.Now));

            Assert.IsNotNull(response.Order);
            Assert.IsTrue(response.Success);
            Assert.AreEqual(1, response.Order.OrderNumber);
        }
Exemple #3
0
        public void Execute()
        {
            ConsoleIO.Header("\t~Single Order~");
            DateTime orderDate = ConsoleIO.DateLookupPrompt();

            FlooringManager manager = FlooringManagerFactory.Create(orderDate);

            ConsoleIO.Header("\t~Single Order~");

            //check if file exists
            //if so:

            Dictionary <int, Order> orderDictionary = manager.GetAllOrders(orderDate);

            if (manager.orderRepository.FileExists())
            {
                if (manager.orderRepository.LastOrder() == true)
                {
                    //DisplaySingleResponse singleResponse = manager.GetOnlyOrder(orderDate);
                    //ConsoleIO.DisplaySingleOrder(singleResponse.Order, true);
                    ConsoleIO.DisplayAllOrders(orderDictionary, false, true, orderDate);
                }
                else
                {
                    int orderNumber = ConsoleIO.GetIntFromUser(ConsoleIO.OrderLookup());

                    DisplaySingleResponse response = manager.LookupOrder(orderNumber, orderDate);

                    if (response.Success)
                    {
                        ConsoleIO.Header("\t~Single Order~");
                        ConsoleIO.DisplaySingleOrder(response.Order, true);
                    }
                    else
                    {
                        //ConsoleIO.ErrorOccurred();
                        //not sure how to put this into ConsoleIO
                        //Console.WriteLine(response.Message);
                        Console.WriteLine();
                        ConsoleIO.InvalidOrder();
                    }
                }
            }

            //else:

            ConsoleIO.KeyToContinue();
            Console.ReadKey();
        }
Exemple #4
0
        public void Execute()
        {
            ConsoleIO.Header("\t~Edit Order~");
            DateTime orderDate = ConsoleIO.DateLookupPrompt();

            FlooringManager    flooringManager   = FlooringManagerFactory.Create(orderDate);
            IOrderRepository   orderRepo         = flooringManager.orderRepository;
            IProductRepository productRepository = flooringManager.productRepository;
            ITaxRepository     taxRepository     = flooringManager.taxRepository;

            ConsoleIO.Header("\t~Edit Order~");
            Dictionary <int, Order> orderDictionary = flooringManager.GetAllOrders(orderDate);

            //Order singleOrder = orderDictionary.TakeWhile(o=>o.Value.OrderDate==orderDate)

            if (orderRepo.FileExists())
            {
                if (orderRepo.LastOrder() == true)
                {
                    ConsoleIO.DisplayAllOrders(orderDictionary, false, true, orderDate);
                    Console.WriteLine();
                    string input = ConsoleIO.YOrNMessage("edit");
                    if (input == "Y")
                    {
                        DisplaySingleResponse singleResponse = flooringManager.GetOnlyOrder(orderDate);

                        ConsoleIO.EditOrder(singleResponse.Order, flooringManager.GetAllTaxes(), flooringManager.GetAllProducts());
                        ConsoleIO.Header("\t~Edit Order");
                        ConsoleIO.DisplaySingleOrder(singleResponse.Order, true);

                        do
                        {
                            singleResponse.Success = false;

                            string saveAnswer = ConsoleIO.SavePrompt().ToUpper();

                            if (saveAnswer == "Y")
                            {
                                //save and exit
                                //orderRepo.SaveOrder(response.Order);
                                orderRepo.CloseRepo(singleResponse.Order);
                                ConsoleIO.SaveCompleted();
                                singleResponse.Success = true;
                            }
                            else
                            {
                                string editAnswer = ConsoleIO.EditPrompt();
                                if (editAnswer == "Y")
                                {
                                    ConsoleIO.AllowEdit();
                                    ConsoleIO.KeyToContinue();
                                    Console.ReadKey();
                                    ConsoleIO.EditOrder(singleResponse.Order, flooringManager.GetAllTaxes(), flooringManager.GetAllProducts());
                                    ConsoleIO.Header("\t~Edit Order~");
                                    ConsoleIO.DisplaySingleOrder(singleResponse.Order, true);
                                    //edit answer
                                }
                                else if (editAnswer == "N")
                                {
                                    ConsoleIO.ReturnMenu("saving");
                                    singleResponse.Success = true;
                                    //dont save and go back to main menu
                                }
                                else
                                {
                                    //go back to save prompt
                                    ConsoleIO.Header("\t~Edit Order~");
                                    ConsoleIO.DisplaySingleOrder(singleResponse.Order, true);
                                    continue;
                                }
                            }
                        } while (singleResponse.Success != true);
                        //orderRepo.DeleteOrderFile();
                        //Console.WriteLine();
                        //ConsoleIO.OrderRemoved(0, true);
                        //ConsoleIO.KeyToContinue();
                        //Console.ReadKey();
                    }
                    //else
                    //{
                    //    //string editAnswer = ConsoleIO.EditPrompt();
                    //    //if (editAnswer == "Y")
                    //    //{
                    //    //    ConsoleIO.AllowEdit();
                    //    //    ConsoleIO.KeyToContinue();
                    //    //    Console.ReadKey();
                    //    //    ConsoleIO.EditOrder(response.Order, flooringManager.GetAllTaxes(), flooringManager.GetAllProducts());
                    //    //    ConsoleIO.Header("\t~Edit Order~");
                    //    //    ConsoleIO.DisplaySingleOrder(response.Order, true);
                    //    //    //edit answer
                    //    //}
                    //    //else if (editAnswer == "N")
                    //    //{
                    //    //    ConsoleIO.ReturnMenu("saving");
                    //    //    response.Success = true;
                    //    //    //dont save and go back to main menu
                    //    //}
                    //    //else
                    //    //{
                    //    //    //go back to save prompt
                    //    //    ConsoleIO.Header("\t~Edit Order~");
                    //    //    ConsoleIO.DisplaySingleOrder(response.Order, true);
                    //    //    continue;
                    //    //}
                    //}
                }
                else
                {
                    ConsoleIO.Header("\t~Edit Order~");
                    int orderNumber = ConsoleIO.GetIntFromUser(ConsoleIO.OrderLookup());

                    DisplaySingleResponse response = flooringManager.LookupOrder(orderNumber, orderDate);

                    if (response.Success)
                    {
                        ConsoleIO.Header("\t~Edit Order~");
                        ConsoleIO.DisplaySingleOrder(response.Order, true);
                        Console.WriteLine();
                        string input = ConsoleIO.YOrNMessage("edit");
                        if (input == "Y")
                        {
                            ConsoleIO.EditOrder(response.Order, flooringManager.GetAllTaxes(), flooringManager.GetAllProducts());
                            ConsoleIO.Header("\t~Edit Order");
                            ConsoleIO.DisplaySingleOrder(response.Order, true);
                            do
                            {
                                response.Success = false;

                                string saveAnswer = ConsoleIO.SavePrompt().ToUpper();

                                if (saveAnswer == "Y")
                                {
                                    //save and exit
                                    //orderRepo.SaveOrder(response.Order);
                                    orderRepo.CloseRepo(response.Order);
                                    ConsoleIO.SaveCompleted();
                                    response.Success = true;
                                }
                                else
                                {
                                    string editAnswer = ConsoleIO.EditPrompt();
                                    if (editAnswer == "Y")
                                    {
                                        ConsoleIO.AllowEdit();
                                        ConsoleIO.KeyToContinue();
                                        Console.ReadKey();
                                        ConsoleIO.EditOrder(response.Order, flooringManager.GetAllTaxes(), flooringManager.GetAllProducts());
                                        ConsoleIO.Header("\t~Edit Order~");
                                        ConsoleIO.DisplaySingleOrder(response.Order, true);
                                        //edit answer
                                    }
                                    else if (editAnswer == "N")
                                    {
                                        ConsoleIO.ReturnMenu("saving");
                                        response.Success = true;
                                        //dont save and go back to main menu
                                    }
                                    else
                                    {
                                        //go back to save prompt
                                        ConsoleIO.Header("\t~Edit Order~");
                                        ConsoleIO.DisplaySingleOrder(response.Order, true);
                                        continue;
                                    }
                                }
                            } while (response.Success != true);
                        }
                    }
                }
            }
            else
            {
                ConsoleIO.InvalidOrder();
                ConsoleIO.KeyToContinue();
                Console.ReadKey();
            }

            //else
            //{
            //    ConsoleIO.KeyToContinue();
            //    Console.ReadKey();
            //}
        }
Exemple #5
0
        public void Execute()
        {
            ConsoleIO.Header("\t~Add Order~");
            DateTime orderDate = ConsoleIO.GetOrderDate();

            FlooringManager    flooringManager   = FlooringManagerFactory.Create(orderDate);
            IOrderRepository   orderRepo         = flooringManager.orderRepository;
            IProductRepository productRepository = flooringManager.productRepository;
            ITaxRepository     taxRepository     = flooringManager.taxRepository;

            //if (!orderRepo.FileExists())
            //{

            //}
            ConsoleIO.Header("\t~Add Order~");
            string custName = ConsoleIO.GetInputFromUser(ConsoleIO.GetCustName());

            ConsoleIO.Header("\t~Add Order~");
            string state = ConsoleIO.GetCustStateAbbrv(flooringManager.GetAllTaxes(), "\t~Add Order~", false, "");

            ConsoleIO.Header("\t~Add Order~");
            string prodType = ConsoleIO.GetProd(flooringManager.GetAllProducts(), false, "\t~Add Order~", "");

            ConsoleIO.Header("\t~Add Order~");
            decimal area = ConsoleIO.GetArea();

            Product prodChosen = productRepository.GetOrderProd(prodType);
            Tax     taxChosen  = taxRepository.GetOrderTax(state);

            decimal taxRate      = taxChosen.TaxRate;
            decimal cost         = prodChosen.CostPerSquareFoot;
            decimal labor        = prodChosen.LaborCostPerSquareFoot;
            decimal materialCost = area * cost;
            decimal laborCost    = area * labor;
            decimal tax          = ((materialCost + laborCost) * (taxRate / 100));
            decimal total        = materialCost + laborCost + tax;

            Console.Clear();
            AddOrderResponse response = flooringManager.AddOrder(orderDate, custName, state, prodType, area, taxRate, cost, labor, materialCost, laborCost, tax, total, prodChosen);

            //display order after calculations
            do
            {
                ConsoleIO.Header("\t~Add Order~");
                ConsoleIO.DisplaySingleOrder(response.Order, false);
                string saveAnswer = ConsoleIO.SavePrompt().ToUpper();

                if (saveAnswer == "Y")
                {
                    //save and exit
                    orderRepo.SaveOrder(response.Order);
                    orderRepo.CloseRepo(response.Order);
                    Console.WriteLine();
                    ConsoleIO.SaveCompleted();
                    response.Success = true;
                }
                else
                {
                    string editAnswer = ConsoleIO.EditPrompt();
                    if (editAnswer == "Y")
                    {
                        Console.WriteLine();
                        ConsoleIO.AllowEdit();
                        ConsoleIO.KeyToContinue();
                        Console.ReadKey();
                        ConsoleIO.EditOrder(response.Order, flooringManager.GetAllTaxes(), flooringManager.GetAllProducts());
                        //edit answer
                    }
                    else if (editAnswer == "N")
                    {
                        Console.WriteLine();
                        ConsoleIO.ReturnMenu("saving");
                        response.Success = true;
                        //dont save and go back to main menu
                    }
                    else
                    {
                        //go back to save prompt
                        continue;
                    }
                }
            } while (response.Success != true);



            ConsoleIO.KeyToContinue();
            Console.ReadKey();
        }
Exemple #6
0
        public void Execute()
        {
            //bool invalidDate;
            //do
            //{
            //    invalidDate = true;
            ConsoleIO.Header("\t~Remove Order~");
            DateTime orderDate = ConsoleIO.DateLookupPrompt();

            FlooringManager    flooringManager   = FlooringManagerFactory.Create(orderDate);
            IOrderRepository   orderRepo         = flooringManager.orderRepository;
            IProductRepository productRepository = flooringManager.productRepository;
            ITaxRepository     taxRepository     = flooringManager.taxRepository;

            ConsoleIO.Header("\t~Remove Order~");
            Dictionary <int, Order> orderDictionary = flooringManager.GetAllOrders(orderDate);

            //if (!orderRepo.FileExists())
            //{
            //    //Console.WriteLine();
            //    //ConsoleIO.InvalidDate();
            //    ConsoleIO.TryAgain();
            //    Console.ReadKey();
            //}
            //else
            if (orderRepo.FileExists())
            {
                if (orderRepo.LastOrder() == true)
                {
                    ConsoleIO.DisplayAllOrders(orderDictionary, false, true, orderDate);
                    Console.WriteLine();
                    string input = ConsoleIO.YOrNMessage("remove");
                    if (input == "Y")
                    {
                        orderRepo.DeleteOrderFile();
                        Console.WriteLine();
                        ConsoleIO.OrderRemoved(0, true);
                        ConsoleIO.KeyToContinue();
                        Console.ReadKey();
                    }
                    else
                    {
                        Console.WriteLine();
                        ConsoleIO.ReturnMenu("removing");
                        ConsoleIO.KeyToContinue();
                        Console.ReadKey();
                    }
                }
                else
                {
                    ConsoleIO.Header("\t~Remove Order~");
                    int orderNumber = ConsoleIO.GetIntFromUser(ConsoleIO.OrderLookup());

                    DisplaySingleResponse response = flooringManager.LookupOrder(orderNumber, orderDate);
                    //if (response.Success)
                    //{
                    ConsoleIO.DisplaySingleOrder(response.Order, true);
                    Console.WriteLine();
                    string input = ConsoleIO.YOrNMessage("remove");
                    if (input == "Y")
                    {
                        while (orderRepo.RemoveOrder(response.Order.OrderNumber) == false)
                        {
                            ConsoleIO.InvalidOrder();
                            ConsoleIO.TryAgain();
                        }
                        //{
                        //    ConsoleIO.InvalidOrder(orderNumber.ToString());
                        //    ConsoleIO.TryAgain();
                        //} while (orderRepo.RemoveOrder(orderNumber) == false);


                        Console.WriteLine();
                        ConsoleIO.OrderRemoved(orderNumber, false);
                        orderRepo.CloseRepo(response.Order);
                        ConsoleIO.KeyToContinue();
                        Console.ReadKey();
                    }
                }
                //invalidDate = false;

                //}
                //else
                //{
                //    ConsoleIO.ErrorOccurred();
                //    Console.WriteLine(response.Message);
                //}
            }
            else
            {
                ConsoleIO.KeyToContinue();
                Console.ReadKey();
            }

            //} while (invalidDate);
        }