public List<StateTax> GetStateTaxInformation() { if (File.Exists(_filePath)) { var reader = File.ReadAllLines(_filePath); for (int i = 1; i < reader.Length; i++) { var columns = reader[i].Split(','); var state = new StateTax(); state.StateAbbreviation = columns[0]; state.StateName = columns[1]; state.TaxRate = Decimal.Parse(columns[2]); _stateTaxList.Add(state); } } return _stateTaxList; }
public List<StateTax> LoadAll() { var stateTaxList = File.ReadAllLines(FileName); var stateInfo = new List<StateTax>(); // start at position 1, because we don't want the header row for (int i = 1; i < stateTaxList.Length; i++) { // split the csv, this returns a string array of each column value var columns = stateTaxList[i].Split(','); // need a contact object to put the data in var newState = new StateTax(); // read the data into the objects one column at a time, enums are ints, but we need to cast (int) newState.StateAbbreviation = columns[(int) StateTaxColumn.StateAbbreviation]; newState.StateName = columns[(int) StateTaxColumn.StateName]; newState.TaxRate = decimal.Parse(columns[(int) StateTaxColumn.Taxrate]); stateInfo.Add(newState); } return stateInfo; }
public Order() { StateTax = new StateTax(); Product = new Product(); OrderCost = new OrderCost(); }