/// <summary> /// Create new /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void Confirm_OnExecuted(object sender, ExecutedRoutedEventArgs e) { var isOk = await CheckIntegrity(); if (isOk) { var relModel = new RelationshipModel { Name = RelationshipName, Source = SourceTableVm.Model, Destination = DestinationTableVm.Model }; relModel.Attributes.AddRange(GridData); relModel.Optionality = relModel.Attributes.All(t => t.Destination.AllowNull) ? Optionality.Optional : Optionality.Mandatory; relModel.DeleteAction = OnDeleteComboBox.SelectedValue as string; relModel.UpdateAction = OnUpdateComboBox.SelectedValue as string; var updater = new DatabaseUpdater(); string res = updater.AddRelationship(relModel); if (res != null) { await this.ShowMessageAsync("Add foreign key", res); } else { ConnectionInfoViewModel model = new ConnectionInfoViewModel() { DestinationViewModel = DestinationTableVm, SourceViewModel = SourceTableVm, DesignerCanvas = Canvas }; model.RelationshipModel.RefreshModel(relModel); await model.BuildConnection3(DesignerViewModel); DesignerViewModel.ConnectionInfoViewModels.Add(model); DialogResult = true; Close(); } } }