private Task DeleteNote(Note note) { using (var context = new NotesContext()) { var noteDb = context.Notes.FirstOrDefault(x => x.Id == note.Id); noteDb.DeletedDate = DateTime.Now; context.Update(noteDb); context.SaveChanges(); } return(Task.CompletedTask); }
private Task Save() { using (var context = new NotesContext()) { foreach (var note in notes) { var noteDb = context.Notes.FirstOrDefault(x => x.Id == note.Id && x.DeletedDate == null); if (noteDb is null) { context.Add(note); } else { noteDb.Text = note.Text; noteDb.IsCompleted = note.IsCompleted; context.Update(noteDb); } } context.SaveChanges(); } return(Task.CompletedTask); }