|
@@ -562,7 +562,7 @@ namespace TEAMModelOS.Controllers.Common
|
|
StringBuilder stringBuilder = new($"SELECT * FROM c WHERE 1=1 ");
|
|
StringBuilder stringBuilder = new($"SELECT * FROM c WHERE 1=1 ");
|
|
string jointEventId = (request.TryGetProperty("jointEventId", out JsonElement _jointEventId)) ? _jointEventId.ToString() : string.Empty;
|
|
string jointEventId = (request.TryGetProperty("jointEventId", out JsonElement _jointEventId)) ? _jointEventId.ToString() : string.Empty;
|
|
string jointGroupId = (request.TryGetProperty("jointGroupId", out JsonElement _jointGroupId)) ? _jointGroupId.ToString() : string.Empty;
|
|
string jointGroupId = (request.TryGetProperty("jointGroupId", out JsonElement _jointGroupId)) ? _jointGroupId.ToString() : string.Empty;
|
|
- string type = (request.TryGetProperty("type", out JsonElement _type)) ? _type.ToString() : "regular"; //預設取得報名名單
|
|
|
|
|
|
+ string type = (request.TryGetProperty("type", out JsonElement _type)) ? _type.ToString() : "pre"; //regular:正式報名名單 pre:預報名名單 ※預設:"pre"
|
|
bool getFinalCourseFlg = (request.TryGetProperty("getFinal", out JsonElement _getFinal)) ? _getFinal.GetBoolean() : false; //是否要取得可晉級名單
|
|
bool getFinalCourseFlg = (request.TryGetProperty("getFinal", out JsonElement _getFinal)) ? _getFinal.GetBoolean() : false; //是否要取得可晉級名單
|
|
if (string.IsNullOrWhiteSpace(jointEventId)) return BadRequest();
|
|
if (string.IsNullOrWhiteSpace(jointEventId)) return BadRequest();
|
|
//取得活動
|
|
//取得活動
|
|
@@ -582,11 +582,7 @@ namespace TEAMModelOS.Controllers.Common
|
|
{
|
|
{
|
|
stringBuilder.Append($" AND c.creatorId = '{creatorId}' ");
|
|
stringBuilder.Append($" AND c.creatorId = '{creatorId}' ");
|
|
}
|
|
}
|
|
- if(type.Equals("regular"))
|
|
|
|
- {
|
|
|
|
- stringBuilder.Append($" AND (c.type = 'regular' OR NOT IS_DEFINED(c.type) OR IS_NULL(c.type)) ");
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
|
|
+ if(!string.IsNullOrWhiteSpace(type))
|
|
{
|
|
{
|
|
stringBuilder.Append($" AND c.type = '{type}' ");
|
|
stringBuilder.Append($" AND c.type = '{type}' ");
|
|
}
|
|
}
|
|
@@ -697,7 +693,7 @@ namespace TEAMModelOS.Controllers.Common
|
|
string provinceName = (request.TryGetProperty("provinceName", out JsonElement _provinceName)) ? _provinceName.ToString() : string.Empty;
|
|
string provinceName = (request.TryGetProperty("provinceName", out JsonElement _provinceName)) ? _provinceName.ToString() : string.Empty;
|
|
string cityId = (request.TryGetProperty("cityId", out JsonElement _cityId)) ? _cityId.ToString() : string.Empty;
|
|
string cityId = (request.TryGetProperty("cityId", out JsonElement _cityId)) ? _cityId.ToString() : string.Empty;
|
|
string cityName = (request.TryGetProperty("cityName", out JsonElement _cityName)) ? _cityName.ToString() : string.Empty;
|
|
string cityName = (request.TryGetProperty("cityName", out JsonElement _cityName)) ? _cityName.ToString() : string.Empty;
|
|
- string joinType = (request.TryGetProperty("joinType", out JsonElement _joinType)) ? _joinType.ToString() : "pre";
|
|
|
|
|
|
+ string joinType = (request.TryGetProperty("type", out JsonElement _joinType)) ? _joinType.ToString() : "pre"; //regular:正式報名名單 pre:預報名名單 ※預設:"pre"
|
|
string scope = (request.TryGetProperty("scope", out JsonElement _scope)) ? _scope.ToString() : string.Empty;
|
|
string scope = (request.TryGetProperty("scope", out JsonElement _scope)) ? _scope.ToString() : string.Empty;
|
|
List<JointEventGroupBase.JointEventGroupCourse> courseLists = (request.TryGetProperty("courseLists", out JsonElement _courseLists)) ? _courseLists.ToObject<List<JointEventGroupBase.JointEventGroupCourse>>() : null;
|
|
List<JointEventGroupBase.JointEventGroupCourse> courseLists = (request.TryGetProperty("courseLists", out JsonElement _courseLists)) ? _courseLists.ToObject<List<JointEventGroupBase.JointEventGroupCourse>>() : null;
|
|
if (string.IsNullOrWhiteSpace(jointEventId) || string.IsNullOrWhiteSpace(jointGroupId) || string.IsNullOrWhiteSpace(creatorId) || courseLists == null || string.IsNullOrWhiteSpace(scope))
|
|
if (string.IsNullOrWhiteSpace(jointEventId) || string.IsNullOrWhiteSpace(jointGroupId) || string.IsNullOrWhiteSpace(creatorId) || courseLists == null || string.IsNullOrWhiteSpace(scope))
|
|
@@ -706,7 +702,7 @@ namespace TEAMModelOS.Controllers.Common
|
|
}
|
|
}
|
|
//取得活動報名資料
|
|
//取得活動報名資料
|
|
JointEventGroupDb jointCourse = new JointEventGroupDb();
|
|
JointEventGroupDb jointCourse = new JointEventGroupDb();
|
|
- StringBuilder stringBuilder = new($"SELECT * FROM c WHERE c.jointEventId = '{jointEventId}' AND c.jointGroupId = '{jointGroupId}' AND c.creatorId = '{creatorId}' AND ( IS_DEFINED(c.type) = false OR c.type = 'regular' ) ");
|
|
|
|
|
|
+ StringBuilder stringBuilder = new($"SELECT * FROM c WHERE c.jointEventId = '{jointEventId}' AND c.jointGroupId = '{jointGroupId}' AND c.creatorId = '{creatorId}' AND c.type = '{joinType}' ");
|
|
await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIteratorSql(queryText: stringBuilder.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("JointCourse") }))
|
|
await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIteratorSql(queryText: stringBuilder.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("JointCourse") }))
|
|
{
|
|
{
|
|
using var json = await JsonDocument.ParseAsync(item.Content);
|
|
using var json = await JsonDocument.ParseAsync(item.Content);
|
|
@@ -750,7 +746,7 @@ namespace TEAMModelOS.Controllers.Common
|
|
jointCourse.provinceName = provinceName;
|
|
jointCourse.provinceName = provinceName;
|
|
jointCourse.cityId = cityId;
|
|
jointCourse.cityId = cityId;
|
|
jointCourse.cityName = cityName;
|
|
jointCourse.cityName = cityName;
|
|
- jointCourse.type = (joinType.Equals("pre")) ? "pre" : "regular"; //regular:教師正式報名名單 pre:預報名名單
|
|
|
|
|
|
+ jointCourse.type = (joinType.Equals("regular")) ? "regular" : "pre"; //regular:教師正式報名名單 pre:預報名名單 custom:決賽名單
|
|
//courseLists修正:防止course的重複生成
|
|
//courseLists修正:防止course的重複生成
|
|
List<JointEventGroupBase.JointEventGroupCourse> courseListsFix = new List<JointEventGroupBase.JointEventGroupCourse>();
|
|
List<JointEventGroupBase.JointEventGroupCourse> courseListsFix = new List<JointEventGroupBase.JointEventGroupCourse>();
|
|
foreach (JointEventGroupBase.JointEventGroupCourse courseInfo in courseLists)
|
|
foreach (JointEventGroupBase.JointEventGroupCourse courseInfo in courseLists)
|
|
@@ -780,16 +776,19 @@ namespace TEAMModelOS.Controllers.Common
|
|
}
|
|
}
|
|
}
|
|
}
|
|
jointCourse.courseLists = courseListsFix;
|
|
jointCourse.courseLists = courseListsFix;
|
|
- //各Schedule Status計算
|
|
|
|
- jointCourse = await JointService.CalJointCourseGroupScheduleStatusAsync(client, jointEventId, jointGroupId, creatorId, jointCourse, null);
|
|
|
|
|
|
+ //各Schedule Status計算 ※正式報名才記入
|
|
|
|
+ if(jointCourse.type.Equals("regular"))
|
|
|
|
+ {
|
|
|
|
+ jointCourse = await JointService.CalJointCourseGroupScheduleStatusAsync(client, jointEventId, jointGroupId, creatorId, jointCourse, null);
|
|
|
|
+ }
|
|
//報名班級 DB更新
|
|
//報名班級 DB更新
|
|
await client.GetContainer(Constant.TEAMModelOS, "Teacher").UpsertItemAsync<JointEventGroupDb>(jointCourse, new PartitionKey("JointCourse"));
|
|
await client.GetContainer(Constant.TEAMModelOS, "Teacher").UpsertItemAsync<JointEventGroupDb>(jointCourse, new PartitionKey("JointCourse"));
|
|
}
|
|
}
|
|
|
|
|
|
//取得該老師報名該活動該組別且progress="going"的JointExam並生成Exam
|
|
//取得該老師報名該活動該組別且progress="going"的JointExam並生成Exam
|
|
List<JointExam> jointExams = new List<JointExam>();
|
|
List<JointExam> jointExams = new List<JointExam>();
|
|
- ///個人
|
|
|
|
- if (jointCourse.scope.Equals("private"))
|
|
|
|
|
|
+ ///個人、正式報名
|
|
|
|
+ if (jointCourse.scope.Equals("private") && jointCourse.type.Equals("regular"))
|
|
{
|
|
{
|
|
StringBuilder sqlJointExam = new($"SELECT * FROM c WHERE c.jointEventId = '{jointCourse.jointEventId}' AND c.jointGroupId = '{jointCourse.jointGroupId}' AND c.progress = 'going' AND c.examType = 'regular' ");
|
|
StringBuilder sqlJointExam = new($"SELECT * FROM c WHERE c.jointEventId = '{jointCourse.jointEventId}' AND c.jointGroupId = '{jointCourse.jointGroupId}' AND c.progress = 'going' AND c.examType = 'regular' ");
|
|
await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIteratorSql(queryText: sqlJointExam.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("JointExam") }))
|
|
await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIteratorSql(queryText: sqlJointExam.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("JointExam") }))
|
|
@@ -848,6 +847,24 @@ namespace TEAMModelOS.Controllers.Common
|
|
return Ok(new { errCode = "", err = "" });
|
|
return Ok(new { errCode = "", err = "" });
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 將預報名轉為正式報名
|
|
|
|
+ /// </summary>
|
|
|
|
+ [ProducesDefaultResponseType]
|
|
|
|
+ [Authorize(Roles = "IES,HTCommunity")]
|
|
|
|
+ [HttpPost("course/pre-to-regular")]
|
|
|
|
+ public async Task<IActionResult> PreToRegular(JsonElement request)
|
|
|
|
+ {
|
|
|
|
+ var client = _azureCosmos.GetCosmosClient();
|
|
|
|
+ string jointEventId = (request.TryGetProperty("jointEventId", out JsonElement _jointEventId)) ? _jointEventId.ToString() : string.Empty;
|
|
|
|
+ string jointGroupId = (request.TryGetProperty("jointGroupId", out JsonElement _jointGroupId)) ? _jointGroupId.ToString() : string.Empty;
|
|
|
|
+ string creatorId = (request.TryGetProperty("creatorId", out JsonElement _creatorId)) ? _creatorId.ToString() : string.Empty;
|
|
|
|
+ if (string.IsNullOrWhiteSpace(jointEventId)) return BadRequest();
|
|
|
|
+
|
|
|
|
+ var result = await JointService.JointCoursePreToRegularAsync(client, jointEventId, jointGroupId, creatorId);
|
|
|
|
+ return Ok(result);
|
|
|
|
+ }
|
|
|
|
+
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 取得統測評量
|
|
/// 取得統測評量
|
|
/// </summary>
|
|
/// </summary>
|