refactor LeaveReportController to enhance employee sorting by remark and check-in/check-out times #2193
All checks were successful
Build & Deploy Leave Service / build (push) Successful in 1m16s

This commit is contained in:
Suphonchai Phoonsawat 2026-01-14 10:16:42 +07:00
parent 127909d29d
commit 86790cf9f3

View file

@ -2250,7 +2250,11 @@ namespace BMA.EHR.Leave.Service.Controllers
}
}
//employees = employees.OrderBy(x => x.checkInDate).ThenBy(x => x.checkInTimeRaw ?? DateTime.MaxValue).ThenBy(x => x.checkOutTimeRaw ?? DateTime.MaxValue).ToList();
employees = employees.OrderBy(x => x.checkInTimeRaw ?? DateTime.MaxValue).ThenBy(x => x.checkOutTimeRaw ?? DateTime.MaxValue).ToList();
employees = employees
.OrderBy(x => x.remark.Trim() == "" ? 0 : 1) // ข้อมูลที่ไม่มี remark ให้ขึ้นก่อน
.ThenBy(x => x.checkInTimeRaw ?? DateTime.MaxValue).ThenBy(x => x.checkOutTimeRaw ?? DateTime.MaxValue)
.ThenBy(x => x.remark) // จากนั้นจัดเรียงตาม remark
.ToList();
for (int i = 0; i < employees.Count; i++)
{
employees[i].no = i + 1;