Browse Source

修正HiTeach取得學校API region欄位為null會報錯問題

jeff 2 years ago
parent
commit
a199514bd8
1 changed files with 11 additions and 1 deletions
  1. 11 1
      TEAMModelOS/Controllers/Client/HiTeachController.cs

+ 11 - 1
TEAMModelOS/Controllers/Client/HiTeachController.cs

@@ -656,7 +656,17 @@ namespace TEAMModelOS.Controllers.Client
                 School school_base = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>($"{school_code}", new PartitionKey("Base"));
                 School school_base = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>($"{school_code}", new PartitionKey("Base"));
                 if (!string.IsNullOrWhiteSpace(school_base.id))
                 if (!string.IsNullOrWhiteSpace(school_base.id))
                 {
                 {
-                    lang = (school_base.region.Equals("中国")) ? "zh-cn" : (school_base.region.Equals("臺灣")) ? "zh-tw" : "en-us"; //語系
+                    //語系取得
+                    if (!string.IsNullOrEmpty(school_base.region))
+                    {
+                        if (school_base.region.Equals("中国")) lang = "zh-cn";
+                        else if (school_base.region.Equals("臺灣")) lang = "zh-tw";
+                    }
+                    else
+                    {
+                        if (_option.Location.Equals("China")) lang = "zh-cn";
+                    }
+                    //年級、科目、評測類型取得
                     foreach (Period periodinfo in school_base.period)
                     foreach (Period periodinfo in school_base.period)
                     {
                     {
                         periods.Add(new { id= periodinfo.id, name= periodinfo.name });
                         periods.Add(new { id= periodinfo.id, name= periodinfo.name });