public void AddOrder(Order newOrder, Product chosenProduct, TaxRate taxRateForCustomerState, string orderDate) { //Calculates the fields necessary to store in the Order newOrder.CostPerSquareFoot = chosenProduct.CostPerSquareFoot; newOrder.MaterialCost = newOrder.CostPerSquareFoot*newOrder.Area; newOrder.LaborCost = newOrder.Area * chosenProduct.LaborCostPerSquareFoot; newOrder.Tax = (newOrder.LaborCost + newOrder.MaterialCost) * taxRateForCustomerState.TaxPercent; newOrder.Total = newOrder.LaborCost + newOrder.MaterialCost + newOrder.Tax; newOrder.LaborCostPerSquareFoot = chosenProduct.LaborCostPerSquareFoot; }
public List<TaxRate> GetAllTaxRates() { var taxesByState = new List<TaxRate>(); var allLines = File.ReadAllLines("Taxes.txt"); foreach (var line in allLines.Skip(1)) { string[] columns = line.Split('|'); var taxSchedule = new TaxRate(); taxSchedule.State = columns[0]; taxSchedule.TaxPercent = decimal.Parse(columns[1])/100; taxesByState.Add(taxSchedule); } return taxesByState; }
private List<TaxRate> ConvertCSVToOrder(string[] taxesAsStrings) { //create a new Orders List List<TaxRate> output = new List<TaxRate>(); for (int i = 1; i < taxesAsStrings.Length; i++) { if (!string.IsNullOrEmpty(taxesAsStrings[i])) { //set up a new array that splits the row based on "," string[] newRow = taxesAsStrings[i].Split(','); TaxRate tax = new TaxRate(); tax.State = newRow[0]; tax.TaxPercent = decimal.Parse(newRow[1]); //Add this to the Tax object output.Add(tax); } } return output; }