diff --git a/API_SQLuedo/API/Controllers/QueryController.cs b/API_SQLuedo/API/Controllers/QueryController.cs index e0fdb81..0a8c1c4 100644 --- a/API_SQLuedo/API/Controllers/QueryController.cs +++ b/API_SQLuedo/API/Controllers/QueryController.cs @@ -26,7 +26,7 @@ namespace API.Controllers } logger.LogInformation("[INFORMATION] La requête a renvoyé : {result} ", queryResult); - return Ok(queryResult); + return Content(queryResult.Result, "application/json"); } [HttpGet("{database}/Tables")] @@ -42,7 +42,7 @@ namespace API.Controllers } logger.LogInformation("[INFORMATION] La requête a renvoyé : {result} ", queryResult); - return Ok(queryResult); + return Content(queryResult.Result, "application/json"); } @@ -59,7 +59,7 @@ namespace API.Controllers } logger.LogInformation("[INFORMATION] La requête a renvoyé : {result} ", queryResult); - return Ok(queryResult); + return Content(queryResult.Result, "application/json"); } } } diff --git a/API_SQLuedo/API/Service/QueryDataServiceApi.cs b/API_SQLuedo/API/Service/QueryDataServiceApi.cs index f4bff6d..e1a104e 100644 --- a/API_SQLuedo/API/Service/QueryDataServiceApi.cs +++ b/API_SQLuedo/API/Service/QueryDataServiceApi.cs @@ -56,7 +56,6 @@ public class QueryDataServiceApi : IQueryService{ resultList.Add(row); } - string resultJson = JsonConvert.SerializeObject(resultList); QueryDto queryDto = new QueryDto { Result = resultJson }; @@ -104,10 +103,10 @@ public class QueryDataServiceApi : IQueryService{ tableNames.Add(reader["table_name"].ToString()); } - Dictionary tablesDict = new Dictionary(); + List tablesDict = new List(); foreach (string tableName in tableNames) { - tablesDict[tableName] = tableName; + tablesDict.Add(new { TableName = tableName}); } string tablesJson = JsonConvert.SerializeObject(tablesDict); @@ -157,13 +156,13 @@ public class QueryDataServiceApi : IQueryService{ columnsNames.Add(reader["column_name"].ToString()); } - Dictionary columnsDict = new Dictionary(); + /*List columnsDict = new List(); foreach (string colName in columnsNames) { - columnsDict[colName] = colName; - } + columnsDict.Add(new { ColumnName = colName}); + }*/ - string tablesJson = JsonConvert.SerializeObject(columnsDict); + string tablesJson = JsonConvert.SerializeObject(columnsNames); Console.WriteLine(tablesJson);