public List <Student> Load() { if (!File.Exists(_studentsFileName)) { return(StudentsFactory.GetFreshStudents()); } var json = File.ReadAllText(_studentsFileName); var students = JsonConvert.DeserializeObject <List <Student> >(json); return(students); }
public List <Student> Load() { if (!File.Exists(_studentsFileName)) { return(StudentsFactory.GetFreshStudents()); } var lines = File.ReadAllLines(_studentsFileName); var students = new List <Student>(); foreach (var line in lines) { var splits = line.Split('|'); var student = new Student(splits[0], DateTime.Parse(splits[1]), splits[2], splits[3], splits[4]); students.Add(student); } return(students); }