Update ค่าไปตาราง Beginning เมื่อมีการ approve การลา
Some checks failed
release-dev / release-dev (push) Failing after 11s
Some checks failed
release-dev / release-dev (push) Failing after 11s
This commit is contained in:
parent
749b2b68a1
commit
6f9116ead5
2 changed files with 34 additions and 1 deletions
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue