|
@@ -854,13 +854,26 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
// cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
|
|
|
List<string> existScId = new();
|
|
|
StringBuilder strMsg = new($"{_tmdName}【{_tmdId}】管理员账户将{tmdId}的账户移除学校:");
|
|
|
+ //老師
|
|
|
+ if (rmvFromSc) //從老師的學校列表移除該學校
|
|
|
+ {
|
|
|
+ var response = await cosmosClient.GetContainer("TEAMModelOS", "Teacher").ReadItemStreamAsync($"{tmdId}", new PartitionKey("Base"));
|
|
|
+ if (response.Status == 200)
|
|
|
+ {
|
|
|
+ using var json = await JsonDocument.ParseAsync(response.ContentStream);
|
|
|
+ Teacher teacher = json.ToObject<Teacher>();
|
|
|
+ teacher.schools.RemoveAll(s => scIds.Contains(s.schoolId));
|
|
|
+ await cosmosClient.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<Teacher>(teacher, teacher.id, new PartitionKey("Base"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //學校
|
|
|
SchoolTeacher scTeacher = null;
|
|
|
foreach (var scId in scIds)
|
|
|
{
|
|
|
var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync($"{tmdId}", new PartitionKey($"Teacher-{scId}"));
|
|
|
if (response.Status == 200)
|
|
|
{
|
|
|
- if (rmvFromSc)
|
|
|
+ if (rmvFromSc) //將該老師從學校的老師名單中移除
|
|
|
{
|
|
|
await cosmosClient.GetContainer("TEAMModelOS", "School").DeleteItemAsync<SchoolTeacher>($"{tmdId}", new PartitionKey($"Teacher-{scId}"));
|
|
|
}
|