public int DisplayAllAccounts(string file) { Console.Clear(); var ops = new OrderOperations(); //get all orders from the entered file List<Order> allOrdersToDisplay = ops.GetAllOrders(file); Console.WriteLine("\t"); foreach (var a in allOrdersToDisplay) { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("\t************************"); Console.WriteLine("\tOrder Number: {0}", a.OrderNumber); Console.WriteLine("\t************************"); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("\tName: {0}", a.LastName.ToUpper()); Console.WriteLine("\tState: {0}", a.State.ToUpper()); } do { Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("\n PLEASE CH0OSE AN ORDER NUMBER...."); string input = Console.ReadLine(); int OrderNumber; if (int.TryParse(input, out OrderNumber)) { // is this valid order if (ops.GetOrder(file, OrderNumber).Success) { Console.Clear(); return OrderNumber; } } Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("\tThat was not a valid entry...."); log.ErrorMessage = "That was not a valid order number entry UI:DisplayALlAccounts...."; ops.CallingErrorLogRepository(log.ErrorMessage); Console.WriteLine("\tPress enter to continue...."); Console.ReadLine(); } while (true); }
public Order DisplayOrderInformation(string file, int orderNumber) { var ops = new OrderOperations(); //string formattedDate = GetOrderDateFromUser(); //int num = GetOrderNumberFromUser(); var response = ops.GetOrder(file, orderNumber); //_currentOrder = response.OrderInfo; if (response.Success) { _currentOrder = response.OrderInfo; PrintOrderInformation(response.OrderInfo); return _currentOrder; } else { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("\tError occurred!!"); Console.WriteLine(response.Message); Console.WriteLine("\tPress enter to continue..."); log.ErrorMessage = "That was not a valid order UI:DisplayOrdererInfo...."; ops.CallingErrorLogRepository(log.ErrorMessage); Console.ReadLine(); //GetOrderNumberFromUser();//******************** return null; } }
//calls CreateOrder and stores a Order in response. public void PopulateOrder(string formattedDate) { OrderOperations ops = new OrderOperations(); var response = new Response(); Order order = new Order(); bool isValid = false; decimal stateRate = 0; Console.ForegroundColor = ConsoleColor.Yellow; Console.Clear(); Console.WriteLine("\tEnter Account Information"); Console.WriteLine("\t----------------------"); Console.ForegroundColor = ConsoleColor.White; bool checkedInput = true; do { Console.Write("\tLast Name: "); order.LastName = Console.ReadLine(); if (order.LastName.Length <= 0) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("\tThat was not a valid entry.\n\t Please enter a name..."); log.ErrorMessage = "That was not a valid name(name) UI:PopulateOrder/AddWorkflow...."; ops.CallingErrorLogRepository(log.ErrorMessage); checkedInput = false; continue; } checkedInput = ops.ValidateInput(order.LastName.ToCharArray()); if (checkedInput == false) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("\tNo special characters in name are permitted.\n\t Please enter valid name"); log.ErrorMessage = "That was not a valid name(name) UI:PopulateOrder/AddWorkflow...."; ops.CallingErrorLogRepository(log.ErrorMessage); } else { checkedInput = true; } } while (checkedInput == false); do { Console.ForegroundColor = ConsoleColor.White; Console.Write("\tState: "); order.State = Console.ReadLine(); //string state = order.State; if (order.State.Length < 2) { Console.WriteLine("\tThat was not a valid entry.\n Please enter a state..."); log.ErrorMessage = "That was not a valid entry(state) UI:PopulateOrder/AddWorkflow...."; ops.CallingErrorLogRepository(log.ErrorMessage); } else { isValid = true; stateRate = ops.MatchState(order.State); if (stateRate == 0) { isValid = false; } } } while (!isValid); //setting tax rate based on state order.TaxRate = stateRate; Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("\tYour tax rate is {0}: ", order.TaxRate); //-------------PRODUCT----------------------- Product product = new Product(); do { Console.ForegroundColor = ConsoleColor.White; //Console.WriteLine(""); Console.Write("\tPlease enter a product type:\n\t\t Carpet, Laminate, Tile, Wood: "); order.ProductType = Console.ReadLine(); if (order.ProductType.Length > 8 || order.ProductType.Length < 1) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("\tThat was not a valid entry.\n Please enter a product..."); log.ErrorMessage = "That was not a valid entry (product) UI:PopulateOrder...."; ops.CallingErrorLogRepository(log.ErrorMessage); } else { order.CostSqFt = ops.ReturnCostPerSquareFoot(order.ProductType); } } while (order.CostSqFt == 0);// is 0 Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("\tYour cost per square foot is {0:c}: ", order.CostSqFt); // getting labor per square foot order.LaborSqFt = ops.LaborPerSquareFt(order.ProductType); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("\tYour labor per square foot is {0:c}: ", order.LaborSqFt); // getting area do { Console.ForegroundColor = ConsoleColor.White; Console.Write("\tArea: "); string input = Console.ReadLine(); if (input.Length == 0) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("\tThat was not a valid entry.\n\t Please enter a Area..."); log.ErrorMessage = "That was not a valid Area(Area) UI:PopulateOrder/AddWorkflow...."; ops.CallingErrorLogRepository(log.ErrorMessage); order.Area = 0; continue; } order.Area = decimal.Parse(input); if (order.Area <= 0) { Console.WriteLine("\tYou need to get a bigger house!"); log.ErrorMessage = "That was not a valid area (area) UI:PopulateOrder...."; ops.CallingErrorLogRepository(log.ErrorMessage); } } while (order.Area <= 0); // getting material cost order.MaterialCost = ops.MaterialCost(order.ProductType, order.Area); Console.ForegroundColor = ConsoleColor.White; Console.Write("\tMaterial Cost: {0:c} ", order.MaterialCost); //getting labor cost Console.ForegroundColor = ConsoleColor.White; order.LaborCost = ops.LaborCost(order.ProductType, order.Area); Console.Write("\nLabor Cost: {0:c} ", order.LaborCost); //get tax Console.ForegroundColor = ConsoleColor.White; order.Tax = ops.Tax(order.State, order.MaterialCost); Console.Write("\nTax: {0:c} ", order.Tax); //get total Console.ForegroundColor = ConsoleColor.White; Console.Write("\nTotal: {0:c}", order.Total); order.Total = ops.Total(order.MaterialCost, order.Tax, order.LaborCost); Console.WriteLine(); ops.CreateOrder(order, formattedDate); Console.Clear(); Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("\n\tHere is your new order information: \n"); DisplayOrderWorkflow dowf = new DisplayOrderWorkflow(); dowf.PrintOrderInformation(order); Console.ForegroundColor = ConsoleColor.White; }