Update ค่าไปตาราง Beginning เมื่อมีการ approve การลา
Some checks failed
release-dev / release-dev (push) Failing after 11s

This commit is contained in:
Suphonchai Phoonsawat 2025-04-29 15:43:06 +07:00
parent 749b2b68a1
commit 6f9116ead5
2 changed files with 34 additions and 1 deletions

View file

@ -76,6 +76,27 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
return data;
}
public async Task UpdateLeaveUsageAsync(int year, Guid typeId, Guid userId, double day)
{
var pf = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken);
if (pf == null)
{
throw new Exception(GlobalMessages.DataNotFound);
}
var data = await _dbContext.Set<LeaveBeginning>()
.Include(x => x.LeaveType)
.FirstOrDefaultAsync(x => x.LeaveYear == year && x.LeaveTypeId == typeId && x.ProfileId == pf.Id);
if(data == null)
{
throw new Exception(GlobalMessages.DataNotFound);
}
data.LeaveDaysUsed += day;
await _dbContext.SaveChangesAsync();
}
public async Task<LeaveBeginning?> GetByYearAndTypeIdForUserAsync(int year, Guid typeId, Guid userId)
{