public Note[] GetNotes() { using (var ctx = new DataModel()) { return ctx.Notes.ToArray().Select(NoteConverter.FromModel).ToArray(); } }
public Operation[] GetHistory() { using (var ctx = new DataModel()) { return ctx.Operations.ToArray().Select(OperationConverter.FromModel).ToArray(); } }
private void AddToHistory(Operation operation) { using (var ctx = new DataModel()) { ctx.Operations.Add(OperationConverter.ToModel(operation)); ctx.SaveChanges(); } }
private void AddNote(Note note) { using (var ctx = new DataModel()) { ctx.Notes.Add(NoteConverter.ToModel(note)); ctx.SaveChanges(); } }
public void DeleteNote(string id) { int noteId = Convert.ToInt32(id); using (var ctx = new DataModel()) { NoteModel note = ctx.Notes.SingleOrDefault(b => b.Id == noteId); if (note != null) { ctx.Notes.Remove(note); ctx.SaveChanges(); } } }
public void UpdateNote(string id, string titre, string description) { int noteId = Convert.ToInt32(id); using (var ctx = new DataModel()) { NoteModel note = ctx.Notes.SingleOrDefault(b => b.Id == noteId); if (note == null) { note = new NoteModel(); } note.Titre = titre; note.Description = description; ctx.SaveChanges(); } }