public async Task <string> GetConnectionString(ConnectionStringViewModel Conn) { return(await Task.Run(() => { return "Data Source=" + Conn.DataSource + ";Initial Catalog=InventoryNew;User ID=" + Conn.Username + ";Password=" + Conn.Password; })); }
public void AssignToSchemaIni() { var model = new ConnectionStringViewModel(); var prov = Container.GetExportedValue <IDataProviderController>(); model.Reset(prov); Assert.IsNotNull(model); var schemaIni = new SchemaIniElement("name", "value"); model.Configuration = new NamedConnectionElement(); Assert.IsTrue(model.Configuration.SchemaIniSettings.Count == 0); model.Configuration.SchemaIniSettings.Add(schemaIni); Assert.IsTrue(model.Configuration.SchemaIniSettings.Count == 1); var col = new SchemaIniElementCollection(); col.Add(schemaIni); model.Configuration.SchemaIniSettings = col; Assert.IsTrue(model.Configuration.SchemaIniSettings.Count == 1); var SchemaIniSettings = new SchemaIniElementCollection(); SchemaIniSettings.Add(schemaIni); model.Configuration = new NamedConnectionElement(); model.Configuration.SchemaIniSettings = SchemaIniSettings; Assert.IsTrue(model.Configuration.SchemaIniSettings.Count == 1); }
public BrowseConnectionStringWindow() { InitializeComponent(); Model = new ConnectionStringViewModel(this); DataContext = Model; LoadSettings(); }
public async Task <ResponseViewModel <ConnectionStringViewModel> > CheckConnection(string DataSource, string Username, string Password) { ConnectionStringViewModel Connection = new ConnectionStringViewModel(); Connection.DataSource = DataSource; Connection.Username = Username; Connection.Password = Password; return(await dbConnection.IsServerExists(Connection)); }
public ActionResult Index() { try { ConnectionStringViewModel conStringVM = new ConnectionStringViewModel(); conStringVM = ConnectionStringHelper.GetDefaultConnectionString(); return(View(conStringVM)); } catch (Exception) { return(View(new ConnectionStringViewModel())); } }
public static ConnectionStringViewModel GetDefaultConnectionString() { ConnectionStringViewModel conStringVM = new ConnectionStringViewModel(); conStringVM.Name = Constants.ConnectionStringName; conStringVM.ServerNameValue = GetServerName(); conStringVM.SqlServerInstances = GetSqlInstanceNames(); if (conStringVM.SqlServerInstances.Count > 0) { conStringVM.SqlServerInstanceValue = conStringVM.SqlServerInstances.First(); } conStringVM.DatabaseValue = Constants.PersonString; conStringVM.IntegratedSecurityValue = true; conStringVM.ProviderName = Constants.ProviderNameAsSqlClient; return(conStringVM); }
public async Task <ResponseViewModel <ConnectionStringViewModel> > IsServerExists(ConnectionStringViewModel Conn) { ResponseViewModel <ConnectionStringViewModel> ResObj = new ResponseViewModel <ConnectionStringViewModel>(); try { ResObj.IsSuccess = false; string ConnectionString = await GetConnectionString(Conn); InventoryDBContext dbContext = new InventoryDBContext(ConnectionString); if (dbContext.Database.GetService <IRelationalDatabaseCreator>().Exists()) { ResObj.IsSuccess = true; } else { dbContext.Database.EnsureCreated(); ResObj.IsSuccess = true; } } catch (Exception ex) { ResObj.IsSuccess = false; ResObj.ErrorDetails = ex.ToString(); ResObj.ErrorCode = 500; } return(await Task.Run(() => { return ResObj; })); }
public DummyViewBase() { Model = new ConnectionStringViewModel(); }