public Order PullingOrder(int orderNumber) { var repo = OrderRepositoryFactory.CreateOrderRepository(); var pulledOrder = repo.PullOrder(orderNumber); return(pulledOrder); }
public void Execute() { DisplayOrderWorkFlow displayOrder = new DisplayOrderWorkFlow(); string dateToSearch = displayOrder.GetOrderDate(); displayOrder.OrderInformationSearch(dateToSearch); int deleteThisOrderNumber = GetOrderNumberToDelete(); OrderOperations pullOrderOperations = new OrderOperations(OrderRepositoryFactory.CreateOrderRepository()); var order = pullOrderOperations.PullingOrder(deleteThisOrderNumber); OrderOperations remove = new OrderOperations(OrderRepositoryFactory.CreateOrderRepository()); bool isValid = false; string confirm = ""; while (!isValid) { DisplayRemoveOrder(order); Console.WriteLine(); Console.WriteLine("Are you sure?"); Console.WriteLine("Enter (Y) or (N)"); confirm = Console.ReadLine().ToUpper(); if (string.IsNullOrEmpty(confirm)) { isValid = false; Console.WriteLine("Please enter (Y) or (N)"); Console.WriteLine("Press ENTER to continue"); Console.ReadLine(); } else if ((confirm != "N") && (confirm != "Y")) { isValid = false; Console.WriteLine("{0} is not a \"Y\" or \"N\"", confirm); Console.WriteLine("Press ENTER to continue"); Console.ReadLine(); } else { isValid = true; } if (confirm == "Y") { var test = remove.RemoveOrder(deleteThisOrderNumber); Console.Clear(); Console.WriteLine(); Console.WriteLine("The odrer with the number of {0}, has been removed", test); Console.WriteLine("Press ENTER to Continue."); Console.ReadLine(); } } }
public int RemoveOrder(int orderNumber) { var repo = OrderRepositoryFactory.CreateOrderRepository(); var orderInfo = new OrderInfoPackage(); var test = repo.DeleteOrder(orderNumber); orderInfo.OrderInformation = test; return(orderNumber); }
public void Execute() { DisplayOrderWorkFlow displayOrder = new DisplayOrderWorkFlow(); string dateToSearch = displayOrder.GetOrderDate(); displayOrder.OrderInformationSearch(dateToSearch); int editThisOrderNumber = GetOrderNumberToEdit(); OrderOperations pullOrder = new OrderOperations(OrderRepositoryFactory.CreateOrderRepository()); var orderToEdit = pullOrder.PullingOrder(editThisOrderNumber); DisplayOrderToEdit(orderToEdit); }
public void EditSwitch(string areaToEdit, Order order) { AddWorkFlow editAddWorkFlow = new AddWorkFlow(); switch (areaToEdit) { case "1": string updatedName = editAddWorkFlow.GetNameForOrder(); order.CustomerName = updatedName; break; case "2": string updatedState = editAddWorkFlow.GetStateForOrder(); order.State = updatedState; break; case "3": string updatedProductType = editAddWorkFlow.GetProductTypeForOrder(); order.ProductType = updatedProductType; break; case "4": decimal updatedArea = editAddWorkFlow.GetAreaForOrder(); order.Area = updatedArea; break; case "5": OrderOperations updateOrder = new OrderOperations(OrderRepositoryFactory.CreateOrderRepository()); updateOrder.UpdateOrder(order, order.OrderNumber); Console.Clear(); Console.WriteLine("The order with the order number of {0} has been updated", order.OrderNumber); Console.WriteLine("Press ENTER to continue."); Console.ReadLine(); break; default: Console.WriteLine(); Console.WriteLine("{0} is not a valid choice.", areaToEdit); Console.WriteLine("Press ENTER to continue."); Console.ReadLine(); break; } }
//public OrderInfoPackage CreateNewOrder(string name, string state, string productType, decimal area) //{ // var repo = OrderRepositoryFactory.CreateOrderRepository(); // var orderInfo = new OrderInfoPackage(); // StateOperations getStateInfo = new StateOperations(); // var stateInfotmation = getStateInfo.GetStateByName(state); // ProductOperations getProductInfo = new ProductOperations(); // var productInformation = getProductInfo.GetProductByName(productType); // decimal MaterialCost = area*productInformation.MaterialCostPerSqFoot; // decimal LaborCost = area*productInformation.LaborCostPerSqFoot; // decimal TaxTotal = (LaborCost + MaterialCost)*(stateInfotmation.TaxRate/100); // decimal OrderTotal = MaterialCost + LaborCost + TaxTotal; // int newOrderNumber = repo.GetNextOrderNumber(); // Order newOrder = new Order() // { // OrderNumber = newOrderNumber, // CustomerName = name, // DateTime = DateTime.Today.ToShortDateString(), // State = state, // TaxRate = stateInfotmation.TaxRate, // ProductType = productInformation.ProductType, // Area = area, // MaterialCostPerSqFt = productInformation.MaterialCostPerSqFoot, // LaborCostPerSqFt = productInformation.LaborCostPerSqFoot, // TotalMaterialCost = MaterialCost, // TotalLaborCost = LaborCost, // TotalTaxCost = TaxTotal, // TotalOrderCost = OrderTotal // }; // //--------------------------------Try this later------------------------------------- // //Console.WriteLine(); // //foreach (PropertyDescriptor i in TypeDescriptor.GetProperties(newOrder)) // //{ // // string title = i.Name; // // object value = i.GetValue(newOrder); // // Console.WriteLine("{0} {1}", title.PadRight(25), value); // //} // //Console.ReadLine(); // bool goodInformationToAdd = false; // do // { // Console.Clear(); // Console.WriteLine(); // Console.WriteLine("***************************************"); // Console.WriteLine("****Not Committed Order Information****"); // Console.WriteLine("***************************************"); // Console.Write("Order Number:".PadRight(25)); // Console.WriteLine("{0} ", newOrder.OrderNumber); // Console.Write("Date:".PadRight(25)); // Console.WriteLine("{0}", newOrder.DateTime); // Console.Write("Customer Name:".PadRight(25)); // Console.WriteLine("{0}", newOrder.CustomerName); // Console.Write("State Name:".PadRight(25)); // Console.WriteLine("{0}", newOrder.State); // Console.Write("Tax Rate:".PadRight(25)); // Console.WriteLine("{0:p}", (newOrder.TaxRate/100)); // Console.Write("Product Type:".PadRight(25)); // Console.WriteLine("{0}", newOrder.ProductType); // Console.Write("Material Cost Per SQ:".PadRight(25)); // Console.WriteLine("{0:c}", newOrder.MaterialCostPerSqFt); // Console.Write("Labor Cost Per SQ:".PadRight(25)); // Console.WriteLine("{0:C}", newOrder.LaborCostPerSqFt); // Console.Write("Area:".PadRight(25)); // Console.WriteLine("{0}", newOrder.Area); // Console.Write("Total Material Cost:".PadRight(25)); // Console.WriteLine("{0:c}", newOrder.TotalMaterialCost); // Console.Write("Total Labor Cost:".PadRight(25)); // Console.WriteLine("{0:c}", newOrder.TotalLaborCost); // Console.Write("Total Tax Cost:".PadRight(25)); // Console.WriteLine("{0:c}", newOrder.TotalTaxCost); // Console.Write("Total:".PadRight(25)); // Console.WriteLine("{0:c}", newOrder.TotalOrderCost); // Console.WriteLine(); // Console.WriteLine("Is all the information correct?"); // Console.WriteLine("Enter (Y) or (N)"); // string continueAnswer = Console.ReadLine().ToUpper(); // if (continueAnswer == "N") // { // orderInfo.IsValid = false; // return orderInfo; // } // if ((continueAnswer != "N") && (continueAnswer != "Y")) // { // Console.WriteLine("Invalid Choice...ENTER to continue"); // Console.ReadLine(); // } // else if (continueAnswer == "Y") // { // goodInformationToAdd = true; // } // } while (goodInformationToAdd != true); // List<Order> AddingOrder = new List<Order>(); // AddingOrder.Add(newOrder); // var addOrder = repo.CreateOrder(newOrder); // if (addOrder != null) // { // orderInfo.IsValid = true; // } // else // { // orderInfo.IsValid = false; // } // return orderInfo; //} public OrderInfoPackage CreateNewOrder(Order newOrder) { var repo = OrderRepositoryFactory.CreateOrderRepository(); var orderInfo = new OrderInfoPackage(); var test = repo.CreateOrder(newOrder); if (test != null) { orderInfo.IsValid = true; } else { orderInfo.IsValid = false; } return(orderInfo); }
public void OrderInformationSearch(string dateToSearch) { OrderOperations orderOps = new OrderOperations(OrderRepositoryFactory.CreateOrderRepository()); var returnedOrder = orderOps.GetOrder(dateToSearch); if (returnedOrder.IsValid) { _currentOrderList = returnedOrder.OrderInformation; DisplayOrderInformation(); } else { Console.WriteLine(); Console.WriteLine("No order with that date."); Console.WriteLine("Returning to the Main Menu."); } }
public void UpdateOrder(Order order, int orderNumber) { var repo = OrderRepositoryFactory.CreateOrderRepository(); repo.UpdateOrder(order, orderNumber); }
public OrderOperations() { _orderRepo = OrderRepositoryFactory.CreateOrderRepository(); }
public void Execute() { //bool correctData = false; //do //{ string name = GetNameForOrder(); string state = GetStateForOrder(); string productType = GetProductTypeForOrder(); decimal area = GetAreaForOrder(); ProductOperations po = new ProductOperations(); OrderOperations addOrderOperations = new OrderOperations(OrderRepositoryFactory.CreateOrderRepository()); StateOperations so = new StateOperations(); State stateInformation = new State(); Product ProductInfornmation = po.GetProductByName(productType); stateInformation = so.GetStateByName(state); decimal MaterialCost = area * ProductInfornmation.MaterialCostPerSqFoot; decimal LaborCost = area * ProductInfornmation.LaborCostPerSqFoot; decimal TaxTotal = (LaborCost + MaterialCost) * (stateInformation.TaxRate / 100); decimal OrderTotal = MaterialCost + LaborCost + TaxTotal; Order newOrder = new Order() { // OrderNumber = newOrderNumber, CustomerName = name, DateTime = DateTime.Now.ToShortDateString(), State = state, TaxRate = stateInformation.TaxRate, ProductType = ProductInfornmation.ProductType, Area = area, MaterialCostPerSqFt = ProductInfornmation.MaterialCostPerSqFoot, LaborCostPerSqFt = ProductInfornmation.LaborCostPerSqFoot, TotalMaterialCost = MaterialCost, TotalLaborCost = LaborCost, TotalTaxCost = TaxTotal, TotalOrderCost = OrderTotal }; bool isValid = false; string confirm = ""; while (!isValid) { DisplayNewOrder(MaterialCost, LaborCost, TaxTotal, OrderTotal, newOrder); Console.WriteLine(); Console.WriteLine("Is all the information correct?"); Console.WriteLine("Enter (Y) or (N)"); confirm = Console.ReadLine().ToUpper(); if (string.IsNullOrEmpty(confirm)) { isValid = false; Console.WriteLine("Please enter (Y) or (N)"); Console.WriteLine("Press ENTER to continue"); Console.ReadLine(); } else if ((confirm != "N") && (confirm != "Y")) { isValid = false; Console.WriteLine("{0} is not a \"Y\" or \"N\"", confirm); Console.WriteLine("Press ENTER to continue"); Console.ReadLine(); } else { isValid = true; } } if (confirm == "Y") { var test = addOrderOperations.CreateNewOrder(newOrder); if (test.IsValid) { Console.Clear(); Console.WriteLine(); Console.WriteLine("your order was added"); Console.WriteLine(); Console.WriteLine("The order number is {0}", newOrder.OrderNumber); Console.WriteLine("The date of the order is {0}", newOrder.DateTime); Console.WriteLine(); Console.WriteLine("Press ENTER to Continue."); Console.ReadLine(); } } }