fix(form_1_2): guard null date/start_working before .Value to prevent 500
continuous-integration/drone/push Build is passing

GetForm2Report ("ร1. แบบฟอร์มเสนอขอปรับเปลี่ยนชื่อตำแหน่ง") called
.Value on nullable DateTime fields unconditionally, crashing with
InvalidOperationException whenever a record's date or start_working
was null — exactly what happened for form_1_2_uid
377a46dc-7131-4b58-ac7e-c9b54900ac34 (date is null in production).
Mirrors the null-check pattern the sibling GetForm3Report already
uses for the same kind of field.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0153wBt23EjW125ZsADwWVAs
This commit is contained in:
Nut.ไปเรื่อย
2026-09-08 12:48:44 +07:00
parent 3ce12e73fc
commit 540130f52c
+6
View File
@@ -4112,14 +4112,20 @@ namespace rmutr_report.Controllers
[ApiExplorerSettings(GroupName = "reports")]
public IActionResult GetForm2Report([FromRoute] string type,
[FromBody] form_1_2 form1)
{
if (form1.date != null)
{
form1.dates = form1.date.Value.ToString("dd MMMM yyyy", CultureInfo.CreateSpecificCulture("th-TH"));
}
if (form1.start_working != null)
{
form1.day_start_workings =
form1.start_working.Value.ToString("dd", CultureInfo.CreateSpecificCulture("th-TH"));
form1.month_start_workings =
form1.start_working.Value.ToString("MMMM", CultureInfo.CreateSpecificCulture("th-TH"));
form1.year_start_workings =
form1.start_working.Value.ToString("yyyy", CultureInfo.CreateSpecificCulture("th-TH"));
}
var form_1 = new List<form_1_2>() { form1 };
Report report = new Report();