|
@@ -224,7 +224,8 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
}
|
|
|
List<dynamic> stuData = new List<dynamic>();
|
|
|
- first.students.ForEach(x =>
|
|
|
+
|
|
|
+ foreach (var x in first.students)
|
|
|
{
|
|
|
var stu = studentes.Find(s => s.id.Equals(x.id) && s.schoolId.Equals(x.code));
|
|
|
var school = idSchools.Find(s => s.id.Equals(x.code));
|
|
@@ -246,6 +247,18 @@ namespace TEAMModelOS.Controllers
|
|
|
teacherName = clazz?.teacher?.name;
|
|
|
classYear = clazz?.year;
|
|
|
}
|
|
|
+ if (string.IsNullOrWhiteSpace(x.relation)) {
|
|
|
+ try {
|
|
|
+ Student student = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Student).ReadItemAsync<Student>(x.id, new PartitionKey($"Base-{x.code}"));
|
|
|
+ var guardian = student.guardians.FindAll(x => x.mobile.Equals(_mobile));
|
|
|
+ if (guardian.IsNotEmpty()) {
|
|
|
+ x.relation= guardian.First().relation;
|
|
|
+ if (!string.IsNullOrWhiteSpace(x.relation)) {
|
|
|
+ await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Student).UpsertItemAsync<Guardian>(first, new PartitionKey(first.code));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch { }
|
|
|
+ }
|
|
|
stuData.Add(new
|
|
|
{
|
|
|
x.id,
|
|
@@ -266,7 +279,7 @@ namespace TEAMModelOS.Controllers
|
|
|
teacherName,
|
|
|
classYear
|
|
|
});
|
|
|
- });
|
|
|
+ }
|
|
|
return Ok(new { code =200,guardian = new { first.id, first.name, first.picture, first.nickname, first.mobile, students = stuData } });
|
|
|
}
|
|
|
else
|