コード例 #1
0
ファイル: ApiController.cs プロジェクト: ZeroICQ/roflandb-web
        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 }));
            }
        }
コード例 #2
0
        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();
        }
コード例 #3
0
 public void EditSqlScript(long id, [FromBody] SqlRequestModel model)
 {
     dataManager.EditSqlScript(id, model);
 }
コード例 #4
0
 public void EditSqlScript(long id, SqlRequestModel model)
 {
     dal.EditSqlScript(id, model);
 }