worked up to evaluation

This commit is contained in:
nugroho 2025-07-01 00:13:53 +07:00
parent d02f1d447c
commit 62928e1f55

View File

@ -610,11 +610,30 @@ public static partial class APIHandler
await runner.WriteJsonResponse(StatusCodes.Status201Created, "Proker evidence accepted. Journal created successfully."); await runner.WriteJsonResponse(StatusCodes.Status201Created, "Proker evidence accepted. Journal created successfully.");
}); });
}) })
.Map("/evalproker", proker=> .Map("/eval", proker=>
{ {
proker.Run(async runner => proker.Run(async runner =>
{ {
await runner.WriteJsonResponse(StatusCodes.Status501NotImplemented, "Not yet finished."); if (!await runner.RequestValidated(1, "POST", true) || !Auth.TryGetUser(runner, out SafeUser CurrUser) ||
await runner.TryGetBodyJsonAsync(["prokerid", "notes"], CTS.Token) is not Dictionary<string, JsonElement> InElement) return;
if (
InElement["prokerid"].GetString() is not string ProkerID || ProkerID.Equals(string.Empty) ||
InElement["notes"].GetString() is not string Notes || Notes.Equals(string.Empty)
)
{
await runner.WriteJsonResponse(StatusCodes.Status400BadRequest, "Required property values is invalid or out of allowed range.");
return;
}
await RunNonQueryAsync(CS, "INSERT INTO [proker_journal] VALUES (@pjid, @pkid, @owid, 8, @nots, null, @tstp)", Query =>
{
DateTime Now = DateTime.Now;
Query.Parameters.AddWithValue("@pjid", GenerateUuidV7(Now));
Query.Parameters.AddWithValue("@pkid", ProkerID);
Query.Parameters.AddWithValue("@owid", CurrUser.AgentID);
Query.Parameters.AddWithValue("@nots", Notes);
Query.Parameters.AddWithValue("@tstp", Now);
}, CTS.Token);
await runner.WriteJsonResponse(StatusCodes.Status201Created, "Proker evaluation accepted. Journal created successfully.");
}); });
}) })
; ;