Ejemplo n.º 1
0
 public void Remove(Note note)
 {
     using (CalendarDbContext context = new CalendarDbContext())
     {
         var n = context.Notes.FirstOrDefault(x => x.Id.Equals(note.Id));
         if (n != null)
         {
             context.Notes.Remove(n);
             context.SaveChanges();
         }
     }
 }
Ejemplo n.º 2
0
 public void AddOrUpdate(Note note)
 {
     using (CalendarDbContext db = new CalendarDbContext())
     {
         var n = db.Notes.FirstOrDefault(x => x.Id.Equals(note.Id));
         if (n != null)
         {
             n.DateOfPosting = note.DateOfPosting;
             n.Body          = note.Body;
         }
         else
         {
             db.Notes.Add(note);
         }
         db.SaveChanges();
     }
 }