public void OnSave() { bool successfulSave; try { using (var tx = Session.BeginTransaction()) { // this isn't strictly necessary, NHibernate will // automatically do it for us, but it make things // more explicit Session.Update(Model.Action); tx.Commit(); } successfulSave = true; } catch (StaleObjectStateException) { var mergeResult = Presenters.ShowDialog <MergeResult?>("Merge", Model.Action); successfulSave = mergeResult != null; ReplaceSessionAfterError(); } // we call ActionUpdated anyway, either we updated the value ourselves // or we encountered a concurrency conflict, in which case we _still_ // want other parts of the application to update themselves with the values // from the db EventPublisher.Publish(new ActionUpdated { Id = Model.Action.Id }, this); if (successfulSave) { View.Close(); } }