From 46599d1bc52bde08f774ced5494412ba2b17d09f Mon Sep 17 00:00:00 2001 From: Suphonchai Phoonsawat Date: Wed, 27 Dec 2023 09:20:09 +0700 Subject: [PATCH] =?UTF-8?q?fix=20=E0=B8=81=E0=B8=B3=E0=B8=A3=E0=B9=81?= =?UTF-8?q?=E0=B8=AA=E0=B8=94=E0=B8=87=E0=B8=9C=E0=B8=A5=E0=B8=A3=E0=B8=AD?= =?UTF-8?q?=E0=B8=9A=E0=B8=81=E0=B8=B2=E0=B8=A3=E0=B8=A5=E0=B8=87=E0=B9=80?= =?UTF-8?q?=E0=B8=A7=E0=B8=A5=E0=B8=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BMA.EHR.Leave.Service/Controllers/LeaveController.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/BMA.EHR.Leave.Service/Controllers/LeaveController.cs b/BMA.EHR.Leave.Service/Controllers/LeaveController.cs index 7c4e435c..669b27a2 100644 --- a/BMA.EHR.Leave.Service/Controllers/LeaveController.cs +++ b/BMA.EHR.Leave.Service/Controllers/LeaveController.cs @@ -905,25 +905,27 @@ namespace BMA.EHR.Leave.Service.Controllers var pagedProfile = profile.Skip((req.Page - 1) * req.PageSize).Take(req.PageSize).ToList(); - var defaultRound = await _dutyTimeRepository.GetDefaultAsync(); + var getDefaultRound = await _dutyTimeRepository.GetDefaultAsync(); var resultSet = new List(); foreach (var p in pagedProfile) { - var roundId = p.DutyTimeId ?? Guid.Empty; - var round = await _dutyTimeRepository.GetByIdAsync(roundId); var effectiveDate = await _userDutyTimeRepository.GetLastEffectRound(p.Id); + var roundId = effectiveDate != null ? effectiveDate.DutyTimeId : Guid.Empty; + var userRound = await _dutyTimeRepository.GetByIdAsync(roundId); + + var duty = userRound ?? getDefaultRound; var res = new SearchProfileResultDto { ProfileId = p.Id, CitizenId = p.CitizenId, FullName = $"{p.Prefix.Name}{p.FirstName} {p.LastName}", - StartTimeMorning = round != null ? round.StartTimeMorning : defaultRound.StartTimeMorning, - LeaveTimeAfterNoon = round != null ? round.EndTimeAfternoon : defaultRound.EndTimeAfternoon, + StartTimeMorning = duty.StartTimeMorning, + LeaveTimeAfterNoon = duty.EndTimeAfternoon, EffectiveDate = effectiveDate == null ? null : effectiveDate.EffectiveDate.Value.Date }; resultSet.Add(res);