From 360580535a8cc243caeb27f5a03679ef27512062 Mon Sep 17 00:00:00 2001 From: Suphonchai Phoonsawat Date: Tue, 17 Jun 2025 14:19:52 +0700 Subject: [PATCH] fix again --- BMA.EHR.Leave/Controllers/LeaveController.cs | 43 ++++++++++++-------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/BMA.EHR.Leave/Controllers/LeaveController.cs b/BMA.EHR.Leave/Controllers/LeaveController.cs index 9dbdc7d5..8b19a67a 100644 --- a/BMA.EHR.Leave/Controllers/LeaveController.cs +++ b/BMA.EHR.Leave/Controllers/LeaveController.cs @@ -2329,18 +2329,20 @@ namespace BMA.EHR.Leave.Service.Controllers var roundId = effectiveDate != null ? effectiveDate.DutyTimeId : Guid.Empty; var userRound = await _dutyTimeRepository.GetByIdAsync(roundId); - //var checkInData = await _userTimeStampRepository.GetTimestampByDateAsync(data.KeycloakUserId, data.CheckDate); - var checkInData = await _processUserTimeStampRepository.GetTimestampByDateAsync(data.KeycloakUserId, data.CheckDate); + var checkInData = await _userTimeStampRepository.GetTimestampByDateAsync(data.KeycloakUserId, data.CheckDate); + //var checkInData = await _processUserTimeStampRepository.GetTimestampByDateAsync(data.KeycloakUserId, data.CheckDate); var duty = userRound ?? getDefaultRound; - DateTime? resultCheckInDate, resultCheckOutDate; + DateTime? resultCheckInDate, resultCheckOutDate, resultCheckInDateAndTime, resultCheckOutDateAndTime; string resultCheckInTime, resultCheckOutTime; + string resultCheckInLocation = "", resultCheckOutLocation = ""; if (data.CheckInEdit) { resultCheckInDate = data.CheckDate.Date; resultCheckInTime = duty.StartTimeMorning; + resultCheckInLocation = data.POI ?? ""; } else { @@ -2352,6 +2354,7 @@ namespace BMA.EHR.Leave.Service.Controllers { resultCheckOutDate = data.CheckDate.Date; resultCheckOutTime = duty.EndTimeAfternoon; + resultCheckOutLocation = data.POI ?? ""; } else { @@ -2365,6 +2368,11 @@ namespace BMA.EHR.Leave.Service.Controllers } + + resultCheckInDateAndTime = DateTime.Parse($"{resultCheckInDate.Value.Date.ToString("yyyy-MM-dd")} {resultCheckInTime}"); + resultCheckOutDateAndTime = DateTime.Parse($"{resultCheckOutDate.Value.Date.ToString("yyyy-MM-dd")} {resultCheckOutTime}"); + + // create result object to return var resObj = new GetAdditionalCheckRequestHistoryDto { @@ -2376,27 +2384,30 @@ namespace BMA.EHR.Leave.Service.Controllers CheckInTime = resultCheckInTime, CheckOutTime = resultCheckOutTime, - CheckInStatus = checkInData == null ? null : - DateTime.Parse(checkInData.CheckIn.ToString("yyyy-MM-dd HH:mm")) > - DateTime.Parse($"{checkInData.CheckIn.Date.ToString("yyyy-MM-dd")} {duty.StartTimeMorning}") ? - DateTime.Parse(checkInData.CheckIn.ToString("yyyy-MM-dd HH:mm")) > - DateTime.Parse($"{checkInData.CheckIn.ToString("yyyy-MM-dd")} {duty.EndTimeMorning}") ? + CheckInStatus = resultCheckInDateAndTime == null ? null : + DateTime.Parse(resultCheckInDateAndTime.Value.ToString("yyyy-MM-dd HH:mm")) > + DateTime.Parse($"{resultCheckInDate.Value.Date.ToString("yyyy-MM-dd")} {duty.StartTimeMorning}") ? + DateTime.Parse(resultCheckInDateAndTime.Value.ToString("yyyy-MM-dd HH:mm")) > + DateTime.Parse($"{resultCheckInDate.Value.ToString("yyyy-MM-dd")} {duty.EndTimeMorning}") ? "ABSENT" : "LATE" : "NORMAL", - CheckOutStatus = checkInData == null ? null : - checkInData.CheckOut == null ? null : - DateTime.Parse(checkInData.CheckOut.Value.ToString("yyyy-MM-dd HH:mm")) < - DateTime.Parse($"{checkInData.CheckIn.Date.ToString("yyyy-MM-dd")} {duty.EndTimeAfternoon}") ? + CheckOutStatus = resultCheckInDate == null ? null : + resultCheckOutDate == null ? null : + DateTime.Parse(resultCheckOutDateAndTime.Value.ToString("yyyy-MM-dd HH:mm")) < + DateTime.Parse($"{resultCheckInDate.Value.Date.ToString("yyyy-MM-dd")} {duty.EndTimeAfternoon}") ? "ABSENT" : - DateTime.Parse(checkInData.CheckOut.Value.ToString("yyyy-MM-dd HH:mm")) < - DateTime.Parse($"{checkInData.CheckIn.Date.ToString("yyyy-MM-dd")} {duty.EndTimeMorning}") ? + DateTime.Parse(resultCheckOutDateAndTime.Value.ToString("yyyy-MM-dd HH:mm")) < + DateTime.Parse($"{resultCheckInDate.Value.Date.ToString("yyyy-MM-dd")} {duty.EndTimeMorning}") ? "ABSENT" : "NORMAL", - CheckInLocation = checkInData == null ? "" : checkInData.CheckInPOI, - CheckOutLocation = checkInData == null ? "" : checkInData.CheckOutPOI ?? "", + //CheckInLocation = checkInData == null ? "" : checkInData.CheckInPOI, + //CheckOutLocation = checkInData == null ? "" : checkInData.CheckOutPOI ?? "", + + CheckInLocation = resultCheckInLocation, + CheckOutLocation = resultCheckOutLocation, EditReason = data.Comment ?? "", EditStatus = data.Status,