private void ShellViewModelClosing(object sender, CancelEventArgs e) { if (entityController.HasChanges()) { if (entityController.CanSave()) { bool?result = messageService.ShowQuestion(shellService.ShellView, Resources.SaveChangesQuestion); if (result == true) { if (!entityController.Save()) { e.Cancel = true; } } else if (result == null) { e.Cancel = true; } } else { e.Cancel = !messageService.ShowYesNoQuestion(shellService.ShellView, Resources.LoseChangesQuestion); } } }