public void Update(Note noteToEdit, IEnumerable<Category> newCategories)
        {
            NoteWithCategories note = Read(noteToEdit.Id);

            note.Title = noteToEdit.Title;
            note.Message = noteToEdit.Message;
            note.Categories = newCategories;

            var query = Query.EQ("_id", ObjectId.Parse(noteToEdit.Id));
            Notes.Update(query, MongoDB.Driver.Builders.Update.Replace(note));
        }
 public static NoteWithCategories Convert(Note note, IEnumerable<Category> categories)
 {
     return new NoteWithCategories
         {
             Id = note.Id,
             Title = note.Title,
             Message = note.Message,
             Added = note.Added,
             Categories = categories
         };
 }
 public void Create(Note noteToAdd, IEnumerable<Category> newCategories)
 {
     NoteWithCategories note = NoteWithCategories.Convert(noteToAdd, newCategories);
     Notes.Insert(note);
 }