api check-time แกะ profileId จาก token เพื่อไม่ต้องไป call เอาจาก org
All checks were successful
Build & Deploy Leave Service / build (push) Successful in 1m42s
All checks were successful
Build & Deploy Leave Service / build (push) Successful in 1m42s
This commit is contained in:
parent
82a45b6811
commit
df7bebe0ba
1 changed files with 9 additions and 8 deletions
|
|
@ -446,29 +446,30 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
public async Task<ActionResult<ResponseObject>> CheckTimeAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
|
||||
var profileId = ProfileId ?? Guid.Empty;
|
||||
|
||||
// Get user's last check-in record and profile in parallel
|
||||
var dataTask = _userTimeStampRepository.GetLastRecord(userId);
|
||||
var profileTask = _userProfileRepository.GetProfileByKeycloakIdNew2Async(userId, AccessToken);
|
||||
//var profileTask = _userProfileRepository.GetProfileByKeycloakIdNew2Async(userId, AccessToken);
|
||||
var defaultRoundTask = _dutyTimeRepository.GetDefaultAsync();
|
||||
|
||||
await Task.WhenAll(dataTask, profileTask, defaultRoundTask);
|
||||
await Task.WhenAll(dataTask, defaultRoundTask);
|
||||
|
||||
var data = await dataTask;
|
||||
var profile = await profileTask;
|
||||
//var profile = await profileTask;
|
||||
var getDefaultRound = await defaultRoundTask;
|
||||
|
||||
if (profile == null)
|
||||
{
|
||||
throw new Exception(GlobalMessages.DataNotFound);
|
||||
}
|
||||
// if (profile == null)
|
||||
// {
|
||||
// throw new Exception(GlobalMessages.DataNotFound);
|
||||
// }
|
||||
|
||||
if (getDefaultRound == null)
|
||||
{
|
||||
return Error("ไม่พบรอบลงเวลา Default", StatusCodes.Status404NotFound);
|
||||
}
|
||||
|
||||
var effectiveDate = await _userDutyTimeRepository.GetLastEffectRound(profile.Id);
|
||||
var effectiveDate = await _userDutyTimeRepository.GetLastEffectRound(profileId);
|
||||
var roundId = effectiveDate != null ? effectiveDate.DutyTimeId : Guid.Empty;
|
||||
var userRound = await _dutyTimeRepository.GetByIdAsync(roundId);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue