public IActionResult Sql([FromBody] SqlRequestModel r) { if (!ModelState.IsValid) { return(BadRequest(new { validationErrors = ModelState })); } try { IEnumerable <string> titles = null; IEnumerable <object> result = null; ; switch (r.DbType) { case SqlRequestModel.DbTypeEnum.Mysql: (titles, result) = _mysql.Execute(r.User, r.Password, r.Host, r.Port, r.Database, r.Query); break; case SqlRequestModel.DbTypeEnum.Postgres: (titles, result) = _postgres.Execute(r.User, r.Password, r.Host, r.Port, r.Database, r.Query); break; } return(new JsonResult(new { titles = titles, result = result })); } catch (MySqlException e) { return(BadRequest(new { dbError = e.Message })); } catch (PostgresException e) { return(BadRequest(new { dbError = e.Message })); } }
public void EditSqlScript(long id, SqlRequestModel model) { var script = Context.SqlScripts.FirstOrDefault(x => x.Id == id); if (script == null) { throw new BadRequestException("Query doen1t exist."); } script.SqlScriptText = JsonConvert.SerializeObject(model); Context.SaveChanges(); }
public void EditSqlScript(long id, [FromBody] SqlRequestModel model) { dataManager.EditSqlScript(id, model); }
public void EditSqlScript(long id, SqlRequestModel model) { dal.EditSqlScript(id, model); }