fix defect

This commit is contained in:
Suphonchai Phoonsawat 2023-12-18 15:50:42 +07:00
parent c798439c19
commit 0a080b09e4
4 changed files with 57 additions and 12 deletions

View file

@ -525,7 +525,9 @@ namespace BMA.EHR.Leave.Service.Controllers
return Error("ไม่พบรอบการลงเวลาทำงาน Default", StatusCodes.Status404NotFound);
}
var userRound = await _dutyTimeRepository.GetByIdAsync(profile.DutyTimeId ?? Guid.Empty);
var effectiveDate = await _userDutyTimeRepository.GetLastEffectRound(profile.Id);
var roundId = effectiveDate != null ? effectiveDate.DutyTimeId : Guid.Empty;
var userRound = await _dutyTimeRepository.GetByIdAsync(roundId);
// TODO : รอดุึงรอบที่ผูกกับ user
var duty = userRound ?? defaultRound;
@ -684,7 +686,10 @@ namespace BMA.EHR.Leave.Service.Controllers
return Error("ไม่พบรอบการลงเวลา Default", StatusCodes.Status404NotFound);
}
var userRound = await _dutyTimeRepository.GetByIdAsync(profile.DutyTimeId ?? Guid.Empty);
//var userRound = await _dutyTimeRepository.GetByIdAsync(profile.DutyTimeId ?? Guid.Empty);
var effectiveDate = await _userDutyTimeRepository.GetLastEffectRound(profile.Id);
var roundId = effectiveDate != null ? effectiveDate.DutyTimeId : Guid.Empty;
var userRound = await _dutyTimeRepository.GetByIdAsync(roundId);
var duty = userRound ?? defaultRound;
@ -759,7 +764,10 @@ namespace BMA.EHR.Leave.Service.Controllers
return Error("ไม่พบรอบการลงเวลา Default", StatusCodes.Status404NotFound);
}
var userRound = await _dutyTimeRepository.GetByIdAsync(profile.DutyTimeId ?? Guid.Empty);
//var userRound = await _dutyTimeRepository.GetByIdAsync(profile.DutyTimeId ?? Guid.Empty);
var effectiveDate = await _userDutyTimeRepository.GetLastEffectRound(profile.Id);
var roundId = effectiveDate != null ? effectiveDate.DutyTimeId : Guid.Empty;
var userRound = await _dutyTimeRepository.GetByIdAsync(roundId);
var duty = userRound ?? defaultRound;
@ -850,6 +858,8 @@ namespace BMA.EHR.Leave.Service.Controllers
var roundId = p.DutyTimeId ?? Guid.Empty;
var round = await _dutyTimeRepository.GetByIdAsync(roundId);
var effectiveDate = await _userDutyTimeRepository.GetLastEffectRound(p.Id);
var res = new SearchProfileResultDto
{
ProfileId = p.Id,
@ -857,7 +867,7 @@ namespace BMA.EHR.Leave.Service.Controllers
FullName = $"{p.Prefix.Name}{p.FirstName} {p.LastName}",
StartTimeMorning = round != null ? round.StartTimeMorning : defaultRound.StartTimeMorning,
LeaveTimeAfterNoon = round != null ? round.EndTimeAfternoon : defaultRound.EndTimeAfternoon,
EffectiveDate = p.DutyTimeEffectiveDate
EffectiveDate = effectiveDate == null ? null : effectiveDate.EffectiveDate.Value.Date
};
resultSet.Add(res);
}
@ -1014,7 +1024,12 @@ namespace BMA.EHR.Leave.Service.Controllers
{
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
}
var userRound = await _dutyTimeRepository.GetByIdAsync(profile.DutyTimeId ?? Guid.Empty);
//var userRound = await _dutyTimeRepository.GetByIdAsync(profile.DutyTimeId ?? Guid.Empty);
var effectiveDate = await _userDutyTimeRepository.GetLastEffectRound(profile.Id);
var roundId = effectiveDate != null ? effectiveDate.DutyTimeId : Guid.Empty;
var userRound = await _dutyTimeRepository.GetByIdAsync(roundId);
var checkInData = await _userTimeStampRepository.GetTimestampByDateAsync(data.KeycloakUserId, data.CheckDate);
var duty = userRound ?? getDefaultRound;
@ -1240,7 +1255,10 @@ namespace BMA.EHR.Leave.Service.Controllers
return Error("ไม่พบรอบการลงเวลา Default", StatusCodes.Status404NotFound);
}
var userRound = await _dutyTimeRepository.GetByIdAsync(profile.DutyTimeId ?? Guid.Empty);
//var userRound = await _dutyTimeRepository.GetByIdAsync(profile.DutyTimeId ?? Guid.Empty);
var effectiveDate = await _userDutyTimeRepository.GetLastEffectRound(profile.Id);
var roundId = effectiveDate != null ? effectiveDate.DutyTimeId : Guid.Empty;
var userRound = await _dutyTimeRepository.GetByIdAsync(roundId);
var duty = userRound ?? defaultRound;
@ -1314,7 +1332,11 @@ namespace BMA.EHR.Leave.Service.Controllers
{
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
}
var userRound = await _dutyTimeRepository.GetByIdAsync(profile.DutyTimeId ?? Guid.Empty);
//var userRound = await _dutyTimeRepository.GetByIdAsync(profile.DutyTimeId ?? Guid.Empty);
var effectiveDate = await _userDutyTimeRepository.GetLastEffectRound(profile.Id);
var roundId = effectiveDate != null ? effectiveDate.DutyTimeId : Guid.Empty;
var userRound = await _dutyTimeRepository.GetByIdAsync(roundId);
var checkInData = await _userTimeStampRepository.GetTimestampByDateAsync(data.KeycloakUserId, data.CheckDate);
var duty = userRound ?? getDefaultRound;