protected void SaveDBNote(DBNote db_note) { // archive any previously existing note into its own table // TODO: evaluate how we could re-use the same DBNote table, which will save us // a select + reinsert operation if (UseHistory) { var old_note = db.FirstOrDefault <DBNote> (n => n.CompoundPrimaryKey == db_note.CompoundPrimaryKey); if (old_note != null) { var archived_note = new DBArchivedNote().PopulateWith(old_note); // set the last known revision if (Manifest.NoteRevisions.Keys.Contains(db_note.Guid)) { archived_note.LastSyncRevision = Manifest.NoteRevisions[db_note.Guid]; } db.Insert <DBArchivedNote> (archived_note); } } // unforunately, we can't know if that note already exist // so we delete any previous incarnations of that note and // re-insert db.Delete <DBNote> (n => n.CompoundPrimaryKey == db_note.CompoundPrimaryKey); db.Insert(db_note); }
public void DeleteNote(Note note) { var dbNote = note.ToDTONote ().ToDBNote (User); if (UseHistory) { var archived_note = new DBArchivedNote ().PopulateWith(dbNote); if (Manifest.NoteRevisions.ContainsKey (note.Guid)) { archived_note.LastSyncRevision = Manifest.NoteRevisions[note.Guid]; } var stored_note = db.FirstOrDefault<DBArchivedNote> (n => n.CompoundPrimaryKey == archived_note.CompoundPrimaryKey); // if that revision already exists, do not store if (stored_note == null) db.Insert<DBArchivedNote> (archived_note); } db.Delete<DBNote> (n => n.CompoundPrimaryKey == dbNote.CompoundPrimaryKey); }
public void DeleteNote(Note note) { var dbNote = note.ToDTONote().ToDBNote(User); if (UseHistory) { var archived_note = new DBArchivedNote().PopulateWith(dbNote); if (Manifest.NoteRevisions.ContainsKey(note.Guid)) { archived_note.LastSyncRevision = Manifest.NoteRevisions[note.Guid]; } var stored_note = db.FirstOrDefault <DBArchivedNote> (n => n.CompoundPrimaryKey == archived_note.CompoundPrimaryKey); // if that revision already exists, do not store if (stored_note == null) { db.Insert <DBArchivedNote> (archived_note); } } db.Delete <DBNote> (n => n.CompoundPrimaryKey == dbNote.CompoundPrimaryKey); }
protected void SaveDBNote(DBNote db_note) { // archive any previously existing note into its own table // TODO: evaluate how we could re-use the same DBNote table, which will save us // a select + reinsert operation if (UseHistory) { var old_note = db.FirstOrDefault<DBNote> (n => n.CompoundPrimaryKey == db_note.CompoundPrimaryKey); if (old_note != null) { var archived_note = new DBArchivedNote ().PopulateWith (old_note); // set the last known revision if (Manifest.NoteRevisions.Keys.Contains (db_note.Guid)) { archived_note.LastSyncRevision = Manifest.NoteRevisions[db_note.Guid]; } db.Insert<DBArchivedNote> (archived_note); } } // unforunately, we can't know if that note already exist // so we delete any previous incarnations of that note and // re-insert db.Delete<DBNote> (n => n.CompoundPrimaryKey == db_note.CompoundPrimaryKey); db.Insert (db_note); }