/// <summary> /// Store configuration associated with specified <see cref="ViewModel<TController, TModel>"/> in migration tools DB. /// </summary> /// <param name="viewModel">The view model.</param> /// <param name="owner">The owner window.</param> /// <param name="openPath">The path from which to open.</param> public static void Save(ShellViewModel viewModel, Window owner) { if (viewModel.IsDirty) { viewModel.SaveToDB(viewModel.DataModel.Configuration.SessionGroupUniqueId, false); viewModel.ClearViewModels(); } /* * if (!viewModel.IsConfigurationPersisted) * { * SaveAsToDBCommand.Save(viewModel, owner); * } * else * { * MessageBoxResult result = MessageBox.Show("Do you want to overwrite the existing configuration?", "Confirm save configuration", MessageBoxButton.YesNoCancel, MessageBoxImage.Exclamation); * if (result == MessageBoxResult.Yes) * { * viewModel.SaveToDB(viewModel.DataModel.Configuration.SessionGroupUniqueId, false); * } * else if (result == MessageBoxResult.No) * { * SaveAsToDBCommand.Save(viewModel, owner); * } * else * { * // do nothing * } * } */ }
/// <summary> /// Store configuration associated with specified <see cref="ViewModel<TController, TModel>"/> in migration tools DB. /// </summary> /// <param name="viewModel">The view model.</param> /// <param name="owner">The owner window.</param> /// <param name="openPath">The path from which to open.</param> public static bool Save(ShellViewModel viewModel, Window owner) { if (viewModel.DataModel != null) { // Present the SessionGroup name and other bits of metadata for editing // before the configuration is persisted to DB. SaveToDBDialog dlg = new SaveToDBDialog(viewModel); dlg.Owner = owner; dlg.ShowDialog(); if (dlg.DialogResult == true) { return(viewModel.SaveToDB(viewModel.DataModel.Configuration.SessionGroupUniqueId, true)); } } return(false); }