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(); } }
private void AddToHistory(Operation operation) { using (var ctx = new DataModel()) { ctx.Operations.Add(OperationConverter.ToModel(operation)); ctx.SaveChanges(); } }