コード例 #1
0
        //takes new order from prompts in UI and assigns the properties to it
        public void CreateOrder(AddEntryRequest request)
        {
            Order newOrder = new Order();
            newOrder.OrderDate = request.OrderDate;
            newOrder.CustomerName = request.CustomerName;
            newOrder.State = request.State;
            //newOrder.TaxRate=a method and conditional
            newOrder.ProductType = request.ProductType;

            if (request.ProductType == "WOOD")  ////changed to newOrder.Product Type
            {
                newOrder.CostPerSquareFoot = 5.15m;
                newOrder.LaborCostPerSquareFoot = 4.75m;
            }
            else if (request.ProductType == "TILE")  // added else if; CHANGED PRODUCT NAMES TO CAPS
            {
                newOrder.CostPerSquareFoot = 3.50m;
                newOrder.LaborCostPerSquareFoot = 4.15m;
            }
            else if (request.ProductType == "CARPET") // added else if; CHANGED PRODUCT NAMES TO CAPS
            {
                newOrder.CostPerSquareFoot = 2.25m;
                newOrder.LaborCostPerSquareFoot = 2.10m;
            }
            else
            {
                newOrder.CostPerSquareFoot = 1.75m;
                newOrder.LaborCostPerSquareFoot = 2.10m;
            }

            newOrder.Area = request.Area;
            /////////////////////////////
            if (request.State == "OH")
            {
                newOrder.TaxRate = 0.0625M;
                // taxRateOperations.IsAllowedState("OH");

            }
            else if (request.State == "PA")///made them else if
            {
                newOrder.TaxRate = 0.0675M;
            }
            else if (request.State == "MI")// made this else if
            {
                newOrder.TaxRate = 0.0575M;
            }
            else
            {
                newOrder.TaxRate = 0.06M;
            }
            newOrder.MaterialCost = (newOrder.Area * newOrder.CostPerSquareFoot);
            newOrder.LaborCost = (newOrder.Area * newOrder.LaborCostPerSquareFoot);
            newOrder.Tax = (newOrder.Area * newOrder.TaxRate);//Addded this line to calculate total tax
            newOrder.Total = ((newOrder.MaterialCost + newOrder.LaborCost + newOrder.Tax));//changed this line to incorporate tax in the total

            ListofOrders.Add(newOrder);//add my newly created order to my list.
            WriteToFile(ListofOrders);//send my new list with orders from the file and newly added orders and send it my
                                      //writetofile to send my list to the file again.
        }
コード例 #2
0
ファイル: AddEntry.cs プロジェクト: abelbalwierz/resume
 public void AddOrder()
 {
     OrderOperations orderOperations = new OrderOperations();
     orderOperations.LoadOrdersFromFile();
     var request = new AddEntryRequest();
     CreateOrderRequest(request);///not quite sure on the order
     orderOperations.CreateOrder(request);
 }
コード例 #3
0
ファイル: AddEntry.cs プロジェクト: abelbalwierz/resume
        public void CreateOrderRequest(AddEntryRequest request)
        {
            Validate validate = new Validate();

            Console.WriteLine("ORDER ENTRY");
            Console.WriteLine();

            request.CustomerName = validate.PromptforString("Enter customer name: ");
            request.State = validate.PromptforState("Please enter the state abbreviation: IN, PA, MI, OH");
            request.ProductType = validate.PromptforProduct("Please Enter a product: Wood, Tile, Laminate, Carpet ");
            request.Area = validate.PromptforDecimal("Please Enter the Area:");
            request.OrderDate = validate.PromptforDate("Please enter the Date MM/DD/YYYY");
            Console.Clear();
            Console.WriteLine(@"Your order details are:
            Customer Name: {0}
            State: {1}
            Product Type: {2}
            Area: {3:n0}
            Order Date: {4}", request.CustomerName, request.State, request.ProductType, request.Area, request.OrderDate);

            Console.WriteLine();

            Console.WriteLine("Would you like to add this order? (Y)es or (N)o?");
            string newOrderReply = Console.ReadLine().ToUpper();

            if (newOrderReply == "Y")
            {
                OrderOperations orderOperations = new OrderOperations();
                orderOperations.CreateOrder(request);
            }

            else
            {
                DisplayMenu returnToMain = new DisplayMenu();
                returnToMain.MainMenu();
            }
        }