public void SaveNotes(IEnumerable <DomainNote> notes) { var data = new NotebookData { Notes = NoteMapper.Convert(notes.ToList()), TimeStamp = timeProvider.Now }; string json = JsonConvert.SerializeObject(data); // for now, possible exceptions will be handled on the application-level File.WriteAllText(filePath, json); }
public IList <DomainNote> LoadNotes() { if (File.Exists(filePath)) { string json = File.ReadAllText(filePath); var notes = JsonConvert.DeserializeObject <NotebookData>(json).Notes; return(NoteMapper.Convert(notes)); } return(new List <DomainNote>()); }