Example #1
0
        private async void SaveAndConnect()
        {
            try
            {
                ConnectionCore xMLCore = new ConnectionCore();
                if (EditModel != null)
                {
                    EditModel = xMLCore.Connections.FirstOrDefault(x => x.Connection.ConnectionName == EditModel.ConnectionName)?.Connection;

                    EditModel.ConnectionName = ConnModel.ConnectionName;
                    EditModel.ConnType       = ConnModel.ConnType;
                    EditModel.Host           = ConnModel.Host;
                    EditModel.Port           = ConnModel.Port;
                    EditModel.UserName       = ConnModel.UserName;
                    EditModel.Password       = ConnModel.Password;
                    EditModel.BuilderBuildConnection();
                }
                else
                {
                    ConnModel.BuilderBuildConnection();
                    xMLCore.Connections.Insert(0, new TreeViewModel()
                    {
                        Connection = ConnModel
                    });
                }
                xMLCore.ConnectionSerialize();
            }
            catch (Exception ex)
            {
                await dialogCoordinator.ShowMessageAsync(this, $"Error!", $"Error message: {ex.Message}  /r/nStackTrace: {ex.StackTrace}");
            }
        }