แก้ defet
ลงเวลาเข้า-ออกปฏิบัติงาน (เช็คเอ้าท์ออกงานไม่ได้)#220 การลา >> ประเภทลา ลาพักผ่อน (ลาซ้ำ)#361
This commit is contained in:
parent
01309ceceb
commit
305d2d9dc5
3 changed files with 31 additions and 3 deletions
|
|
@ -563,6 +563,18 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
return 0;
|
||||
}
|
||||
|
||||
public async Task<bool> CheckDuplicateLeave(Guid keycloakUserId, DateTime startDate, DateTime endDate)
|
||||
{
|
||||
var data = await _dbContext.Set<LeaveRequest>().AsQueryable()
|
||||
.Include(x => x.Type)
|
||||
.Where(x => x.KeycloakUserId == keycloakUserId)
|
||||
.Where(x => x.LeaveStartDate.Date == startDate.Date || x.LeaveEndDate.Date == endDate.Date)
|
||||
.Where(x => x.LeaveStatus == "DELETE" && x.LeaveStatus == "REJECT")
|
||||
.ToListAsync();
|
||||
|
||||
return data.Count > 0;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -423,7 +423,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
await _minIOService.UploadFileAsync(fileName, ms);
|
||||
}
|
||||
|
||||
var currentCheckInProcess = await _processUserTimeStampRepository.GetTimestampByDateAsync(Guid.Parse(UserId), currentDate);
|
||||
|
||||
|
||||
var defaultRound = await _dutyTimeRepository.GetDefaultAsync();
|
||||
if (defaultRound == null)
|
||||
|
|
@ -490,7 +490,12 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
var checkout = await _userTimeStampRepository.GetByIdAsync(data.CheckInId.Value);
|
||||
|
||||
var currentCheckInProcess = await _processUserTimeStampRepository.GetTimestampByDateAsync(Guid.Parse(UserId), checkout.CheckIn.Date);
|
||||
|
||||
var checkout_process = await _processUserTimeStampRepository.GetByIdAsync(currentCheckInProcess.Id);
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -114,6 +114,13 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
public async Task<ActionResult<ResponseObject>> CreateLeaveRequestAsync([FromForm] CreateLeaveRequestDto req)
|
||||
{
|
||||
var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
|
||||
|
||||
var isDuplicate = await _leaveRequestRepository.CheckDuplicateLeave(userId, req.LeaveStartDate.Date, req.LeaveEndDate.Date);
|
||||
if (isDuplicate)
|
||||
{
|
||||
return Error("ไม่สามารถขอลาในช่วงเวลาเดียวกันได้");
|
||||
}
|
||||
|
||||
var thisYear = DateTime.Now.Year;
|
||||
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId);
|
||||
|
|
@ -327,11 +334,15 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
return Error(GlobalMessages.DataNotFound);
|
||||
}
|
||||
|
||||
|
||||
|
||||
var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
|
||||
var thisYear = DateTime.Now.Year;
|
||||
|
||||
var isDuplicate = await _leaveRequestRepository.CheckDuplicateLeave(userId, req.LeaveStartDate.Date, req.LeaveEndDate.Date);
|
||||
if (isDuplicate)
|
||||
{
|
||||
return Error("ไม่สามารถขอลาในช่วงเวลาเดียวกันได้");
|
||||
}
|
||||
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId);
|
||||
|
||||
if (profile == null)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue