private List <SchemaVersion> RunScripts(List <SchemaVersion> files) { var runner = new SqlRunner(ApplicationConfiguration.ConnectionString); var results = runner.RunScripts(files); return(results); }
public ActionResult Index(DatabaseSetupModel databaseSetupModel) { var isCredentialsValid = _dbContext.IsCredentialsValid(databaseSetupModel.ConnectionString); if (ModelState.IsValid && isCredentialsValid) { var files = _pathMapper.GetAvailableScripts().ToList(); try { var runner = new SqlRunner(ApplicationConfiguration.ConnectionString); var results = runner.RunScripts(files); UpdateScriptsRan(results); return(RedirectToRoute("SetupIndex")); } catch (Exception exception) { databaseSetupModel.Message = "Unable to complete the installation, scroll below..."; databaseSetupModel.MessageCss = "error"; databaseSetupModel.CompleteException = exception.ToString(); } } if (!string.IsNullOrEmpty(databaseSetupModel.ConnectionString) && !isCredentialsValid) { databaseSetupModel.Message = "An invalid connection string was entered"; databaseSetupModel.MessageCss = "error"; } databaseSetupModel.Scripts = _pathMapper.GetAvailableScripts().ToList().Select(s => Path.GetFileName(s.ScriptPath)).ToList(); return(View(databaseSetupModel)); }