fix กำรแสดงผลรอบการลงเวลา

This commit is contained in:
Suphonchai Phoonsawat 2023-12-27 09:20:09 +07:00
parent 5652a1cf03
commit 46599d1bc5

View file

@ -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<SearchProfileResultDto>();
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);