Add IsProbatin property to GetProfileByKeycloakIdDto and update leave request logic for probationary users #2266
This commit is contained in:
parent
970319e8c2
commit
358fd47b99
3 changed files with 43 additions and 24 deletions
|
|
@ -926,9 +926,17 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
var profile = await _userProfileRepository.GetProfileByKeycloakIdNewAsync(userId, data.Token);
|
||||
|
||||
if (profile == null)
|
||||
{
|
||||
await _checkInJobStatusRepository.UpdateToFailedAsync(taskId, "ไม่พบข้อมูลผู้ใช้");
|
||||
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||
}
|
||||
|
||||
if (data.CheckInFileName == "no-file") throw new Exception(GlobalMessages.NoFileToUpload);
|
||||
if (data.CheckInFileName == "no-file")
|
||||
{
|
||||
//throw new Exception(GlobalMessages.NoFileToUpload);
|
||||
await _checkInJobStatusRepository.UpdateToFailedAsync(taskId, GlobalMessages.NoFileToUpload);
|
||||
return Error(GlobalMessages.NoFileToUpload, StatusCodes.Status400BadRequest);
|
||||
}
|
||||
var currentDate = data.CurrentDate ?? DateTime.Now;
|
||||
|
||||
var check_status = data.CheckInId == null ? "check-in-picture" : "check-out-picture";
|
||||
|
|
@ -970,6 +978,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
|
||||
if (currentCheckIn != null)
|
||||
{
|
||||
await _checkInJobStatusRepository.UpdateToFailedAsync(taskId, "ไม่สามารถลงเวลาได้ เนื่องจากมีการลงเวลาในวันนี้แล้ว");
|
||||
return Error(new Exception("ไม่สามารถลงเวลาได้ เนื่องจากมีการลงเวลาในวันนี้แล้ว!"), StatusCodes.Status400BadRequest);
|
||||
}
|
||||
|
||||
|
|
@ -1104,31 +1113,35 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
else
|
||||
{
|
||||
var checkout = await _userTimeStampRepository.GetByIdAsync(data.CheckInId.Value);
|
||||
|
||||
var currentCheckInProcess = await _processUserTimeStampRepository.GetTimestampByDateAsync(userId, checkout.CheckIn.Date);
|
||||
|
||||
var checkout_process = await _processUserTimeStampRepository.GetByIdAsync(currentCheckInProcess.Id);
|
||||
|
||||
|
||||
if (checkout != null)
|
||||
{
|
||||
checkout.CheckOutLat = data.Lat;
|
||||
checkout.CheckOutLon = data.Lon;
|
||||
checkout.IsLocationCheckOut = data.IsLocation;
|
||||
checkout.CheckOutLocationName = data.LocationName;
|
||||
checkout.CheckOutPOI = data.POI;
|
||||
checkout.CheckOutRemark = data.Remark;
|
||||
checkout.CheckOutImageUrl = fileName;
|
||||
checkout.CheckOut = currentDate;
|
||||
|
||||
await _userTimeStampRepository.UpdateAsync(checkout);
|
||||
}
|
||||
else
|
||||
|
||||
if (checkout == null)
|
||||
{
|
||||
await _checkInJobStatusRepository.UpdateToFailedAsync(taskId, "ไม่พบข้อมูลการลงเวลาทำงาน");
|
||||
return Error(new Exception(GlobalMessages.DataNotFound), StatusCodes.Status404NotFound);
|
||||
}
|
||||
|
||||
var currentCheckInProcess = await _processUserTimeStampRepository.GetTimestampByDateAsync(userId, checkout.CheckIn.Date);
|
||||
|
||||
if (currentCheckInProcess == null)
|
||||
{
|
||||
await _checkInJobStatusRepository.UpdateToFailedAsync(taskId, "ไม่พบข้อมูลการประมวลผลเวลาทำงาน (CheckIn)");
|
||||
return Error(new Exception(GlobalMessages.DataNotFound), StatusCodes.Status404NotFound);
|
||||
}
|
||||
|
||||
var checkout_process = await _processUserTimeStampRepository.GetByIdAsync(currentCheckInProcess.Id);
|
||||
|
||||
// Update checkout record
|
||||
checkout.CheckOutLat = data.Lat;
|
||||
checkout.CheckOutLon = data.Lon;
|
||||
checkout.IsLocationCheckOut = data.IsLocation;
|
||||
checkout.CheckOutLocationName = data.LocationName;
|
||||
checkout.CheckOutPOI = data.POI;
|
||||
checkout.CheckOutRemark = data.Remark;
|
||||
checkout.CheckOutImageUrl = fileName;
|
||||
checkout.CheckOut = currentDate;
|
||||
|
||||
await _userTimeStampRepository.UpdateAsync(checkout);
|
||||
|
||||
var endTime = "";
|
||||
var startTime = "";
|
||||
var endTimeMorning = "";
|
||||
|
|
@ -1289,7 +1302,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
{
|
||||
await _checkInJobStatusRepository.UpdateToFailedAsync(taskId, ex.Message);
|
||||
}
|
||||
throw;
|
||||
return Error(ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue