Beispiel #1
0
 public MainWindow()
 {
     InitializeComponent();
     using (var context = new NotesContext())
     {
         notes = context.Notes.Where(x => x.DeletedDate == null).ToList();
     }
     notesDG.ItemsSource = notes;
 }
Beispiel #2
0
 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);
 }
Beispiel #3
0
 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);
 }
Beispiel #4
0
 public NotesController(NotesContext context)
 {
     _context = context;
 }