public void GetTaxRateForTest() { TaxRate result = TaxRateOperations.GetTaxRateFor("OH"); Assert.IsNotNull(result); Assert.AreEqual(result.State, "OH"); Assert.AreEqual(result.TaxPercent, 6.25M); }
private static string PromptForValidState(string prompt, bool extraInfo = false) { string state = ""; bool validState = false; bool error = false; while (!validState) { OffsetTop(); DisplayValidStates(); if (error) { Console.ForegroundColor = ErrorColor; Console.WriteLine("\tInvalid State."); Console.WriteLine(); } Console.ForegroundColor = PromptColor; Console.Write("\t" + prompt); Console.ForegroundColor = EmphasisColor; state = Console.ReadLine().Trim().ToUpper(); Console.Clear(); Console.ResetColor(); if (TaxRateOperations.IsAllowedState(state)) { if (extraInfo) { TaxRate rate = TaxRateOperations.GetTaxRateFor(state); OffsetTop(); Console.WriteLine("\tThe tax rate for {0} is {1:p}", rate.State, rate.TaxPercent * 0.01M); Console.WriteLine("\t----------------------------------------"); Console.WriteLine(); } validState = true; } else { error = true; } } return(state); }
public void AddOrder() { OrderOperations orderOps = new OrderOperations(); CustomerInput custIn = new CustomerInput(); bool isValidName = false; Console.Clear(); Console.WriteLine("Add Order"); Console.WriteLine("***************************\n"); while (!isValidName) { Console.Write("Please enter the customer name: "); custIn.CustName = Console.ReadLine(); isValidName = !string.IsNullOrEmpty(custIn.CustName); } bool isValidState = false; while (!isValidState) { Console.Write("\nPlease enter a state: "); custIn.State = Console.ReadLine().ToUpper(); TaxRateOperations taxOps = new TaxRateOperations(); if (taxOps.IsAllowedState(custIn.State)) { Console.WriteLine("\nThat is a valid state"); TaxRate rate = taxOps.GetTaxRateFor(custIn.State); isValidState = true; Console.WriteLine("\nThe tax rate for {0} is {1:p}", rate.State, rate.TaxPercent); } else { Console.WriteLine("\nThat is not a valid state"); } } bool isValidProduct = false; while (!isValidProduct) { Console.Write("\nPlease enter a product type: "); custIn.ProductType = Console.ReadLine(); ProductOperations prodOps = new ProductOperations(); if (prodOps.IsExistingProduct(custIn.ProductType)) { Console.WriteLine("\nThat is a valid product."); Product prod = prodOps.GetProductFor(custIn.ProductType); isValidProduct = true; } else { Console.WriteLine("\nThat is not one of our products."); } } bool isValidArea = false; while (!isValidArea) { Console.Write("\nPlease enter flooring area in square feet: "); decimal floorArea; bool isDecimal = decimal.TryParse(Console.ReadLine(), out floorArea); if (isDecimal) { isValidArea = true; custIn.Area = floorArea; } } Console.Write("\nReady to create new order? Y/N "); if (Console.ReadLine().ToUpper() == "N") { MenuDisplay(); } custIn.OrderNumber = 0; DateTime orderDate = default(DateTime); orderOps.CreateNewOrder(custIn, orderDate); Console.WriteLine("\nOk, your order has been created!"); Console.ReadLine(); }