|
@@ -39,55 +39,57 @@ namespace TEAMModelOS.Controllers.Syllabus
|
|
|
/// <param name="request"></param>
|
|
|
/// <returns></returns>
|
|
|
[HttpPost("DataDefault")]
|
|
|
- public BaseJosnRPCResponse DataDefault(JosnRPCRequest<bool> request)
|
|
|
+ public async Task<BaseJosnRPCResponse> DataDefaultAsync(JosnRPCRequest<bool> request)
|
|
|
{
|
|
|
- JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
|
|
|
+ //JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
|
|
|
string contentRootPath = webHostEnvironment.ContentRootPath;
|
|
|
- string data = getJson(contentRootPath, "/JsonFile/Core/BaseDataDefault.json");
|
|
|
- JArray parsedJson = JArray.Parse(data);
|
|
|
- if (!request.@params)
|
|
|
- {
|
|
|
- List<JObject> jsonElements = new List<JObject>();
|
|
|
- foreach (JObject element in parsedJson)
|
|
|
- {
|
|
|
- if (element.TryGetValue("lang", out JToken json))
|
|
|
- {
|
|
|
- if (json.ToString().Equals(request.lang))
|
|
|
- {
|
|
|
- jsonElements.Add(element);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return builder.Data(jsonElements).build();
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- return builder.Data(parsedJson).build();
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- //JsonDocument document = await GetJson(contentRootPath, "/JsonFile/Core/BaseDataDefault.json");
|
|
|
+ //string data = getJson(contentRootPath, "/JsonFile/Core/BaseDataDefault.json");
|
|
|
+ //JArray parsedJson = JArray.Parse(data);
|
|
|
//if (!request.@params)
|
|
|
//{
|
|
|
- // List<JsonElement> jsonElements = new List<JsonElement>();
|
|
|
- // foreach (JsonElement element in document.RootElement.EnumerateArray())
|
|
|
+ // List<JObject> jsonElements = new List<JObject>();
|
|
|
+ // foreach (JObject element in parsedJson)
|
|
|
// {
|
|
|
- // if (element.TryGetProperty("lang", out JsonElement json))
|
|
|
+ // if (element.TryGetValue("lang", out JToken json))
|
|
|
// {
|
|
|
- // if (json.GetString().Equals(request.lang))
|
|
|
+ // if (json.ToString().Equals(request.lang))
|
|
|
// {
|
|
|
// jsonElements.Add(element);
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
+
|
|
|
// return builder.Data(jsonElements).build();
|
|
|
//}
|
|
|
//else
|
|
|
//{
|
|
|
- // return builder.Data(document.RootElement).build();
|
|
|
+ // return builder.Data(parsedJson).build();
|
|
|
//}
|
|
|
+
|
|
|
+ JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
|
|
|
+
|
|
|
+ JsonDocument document = await GetJson(contentRootPath, "/JsonFile/Core/BaseDataDefault.json");
|
|
|
+ if (!request.@params)
|
|
|
+ {
|
|
|
+ List<JsonElement> jsonElements = new List<JsonElement>();
|
|
|
+ foreach (JsonElement element in document.RootElement.EnumerateArray())
|
|
|
+ {
|
|
|
+ if (element.TryGetProperty("lang", out JsonElement json))
|
|
|
+ {
|
|
|
+ if (json.GetString().Equals(request.lang))
|
|
|
+ {
|
|
|
+ jsonElements.Add(element);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //return JsonDocument.Parse(jsonElements.ToApiJson()).RootElement;
|
|
|
+ return builder.Data(JsonDocument.Parse(jsonElements.ToApiJson()).RootElement).build();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //return document.RootElement;
|
|
|
+ return builder.Data(document.RootElement).build();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|