|
@@ -218,12 +218,8 @@ namespace TEAMModelOS.Controllers
|
|
|
|
|
|
try
|
|
|
{
|
|
|
-
|
|
|
string school_code = code.ToString();
|
|
|
-
|
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
|
- Class classroom = await client.GetContainer(Constant.TEAMModelOS, "School").DeleteItemAsync<Class>(id.ToString(), new PartitionKey($"Class-{school_code}"));
|
|
|
-
|
|
|
List<Student> students = new List<Student>();
|
|
|
await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryIterator<Student>(queryText: $"select * from c where c.classId='{id}' ", requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"Base-{code}") }))
|
|
|
{
|
|
@@ -235,7 +231,6 @@ namespace TEAMModelOS.Controllers
|
|
|
{
|
|
|
tasks.Add(client.GetContainer(Constant.TEAMModelOS, "Student").ReplaceItemAsync(stu, stu.id, new PartitionKey(($"Base-{code}"))));
|
|
|
}
|
|
|
-
|
|
|
GroupChange change = new GroupChange();
|
|
|
if (students.IsNotEmpty()) {
|
|
|
change.stuleave.AddRange(students.Select(x=> new Member {
|
|
@@ -249,10 +244,10 @@ namespace TEAMModelOS.Controllers
|
|
|
code = $"{code}"
|
|
|
}));
|
|
|
}
|
|
|
- change.listid = classroom.id;
|
|
|
+ change.listid = $"{id}";
|
|
|
change.scope = "school";
|
|
|
change.originCode = $"{code}";
|
|
|
- change.school = classroom.school;
|
|
|
+ change.school = $"{school_code}";
|
|
|
change.type = "class";
|
|
|
change.status = "delete";
|
|
|
var messageChange = new ServiceBusMessage(change.ToJsonString());
|
|
@@ -260,6 +255,8 @@ namespace TEAMModelOS.Controllers
|
|
|
var ActiveTask = _configuration.GetValue<string>("Azure:ServiceBus:ActiveTask");
|
|
|
await _serviceBus.GetServiceBusClient().SendMessageAsync(ActiveTask, messageChange);
|
|
|
//查询含有该班级的课程ID
|
|
|
+
|
|
|
+ /*
|
|
|
List<string> cids = new List<string>();
|
|
|
await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(
|
|
|
queryText: $"select distinct c.id from c join A0 in c.schedule where A0.classId = '{id}'",
|
|
@@ -288,7 +285,6 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //courses.ForEach(c => c.schedule.Where(s => !string.IsNullOrEmpty(s.classId)&& s.classId.Equals(id))
|
|
|
foreach (Course course in courses)
|
|
|
{
|
|
|
for (int i =0;i< course.schedule.Count;i++) {
|
|
@@ -301,9 +297,10 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
taskCourses.Add(client.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync(course, course.id, new PartitionKey((course.code))));
|
|
|
}
|
|
|
-
|
|
|
- await Task.WhenAll(tasks);
|
|
|
await Task.WhenAll(taskCourses);
|
|
|
+ */
|
|
|
+ await Task.WhenAll(tasks);
|
|
|
+ Class classroom= await client.GetContainer(Constant.TEAMModelOS, "School").DeleteItemAsync<Class>(id.ToString(), new PartitionKey($"Class-{school_code}"));
|
|
|
return Ok(new { classroom });
|
|
|
}
|
|
|
catch (Exception ex)
|