Add UpdateLeaveCountAsync method to LeaveBeginningRepository and integrate it into leave request logic #2288
All checks were successful
Build & Deploy Leave Service / build (push) Successful in 1m17s
All checks were successful
Build & Deploy Leave Service / build (push) Successful in 1m17s
This commit is contained in:
parent
639d41649c
commit
d3cc0781cf
2 changed files with 26 additions and 0 deletions
|
|
@ -99,6 +99,28 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
await _dbContext.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task UpdateLeaveCountAsync(int year, Guid typeId, Guid userId, int count)
|
||||
{
|
||||
// var pf = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken);
|
||||
var pf = await _userProfileRepository.GetProfileByKeycloakIdNewAsync(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.LeaveCount += count;
|
||||
|
||||
await _dbContext.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task<LeaveBeginning?> GetByYearAndTypeIdForUserAsync(int year, Guid typeId, Guid userId)
|
||||
{
|
||||
// var pf = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue