Ejemplo n.º 1
0
 public void UpdateState(StateDto stateToUpdate)
 {
     var statesList = ReadAllStates();
     var existingState = statesList.First(s => s.StateAbbreviaton == stateToUpdate.StateAbbreviaton);
     statesList.Remove(existingState);
     statesList.Add(stateToUpdate);
     OverwriteFile(statesList);
 }
Ejemplo n.º 2
0
        public List<StateDto> ReadAllStates()
        {
            List<StateDto> statesList = new List<StateDto>();

            var reader = File.ReadAllLines(FilePath);

            for (int i = 1; i < reader.Length; i++)
            {
                var columns = reader[i].Split(',');

                var state = new StateDto();

                state.StateAbbreviaton = columns[0];
                state.StateName = columns[1];
                state.TaxRate = decimal.Parse(columns[2]);
                statesList.Add(state);
            }

            return statesList;
        }
Ejemplo n.º 3
0
 public void CreateState(StateDto inStateDto)
 {
     var statesList = ReadAllStates();
     statesList.Add(inStateDto);
     OverwriteFile(statesList);
 }