public bool CanClose() { if (!_stateManager.IsDirty()) { return(true); } string message = "Select OK to save changes to {0}, No to discard changes or cancel to continue editing".ToFormat( _test.Name); UserMessageResponse dialogResult = _messageBox.AskUserCanCancel("Unsaved Changes", message); bool result = false; //Something better to do here than a switch statement I'm sure. switch (dialogResult) { //User says to save changes (OK) case UserMessageResponse.Yes: var applied = _controller.SaveChanges(); if (!applied) { throw new NotImplementedException(); } result = true; break; //User says cancel close changes (No) case UserMessageResponse.Cancel: break; //User says discard changes (cancel) default: result = true; break; } return(result); }