fix LV1_003 - ลบรอบการปฏิบัติงาน (ADMIN)#3

This commit is contained in:
Suphonchai Phoonsawat 2023-12-18 16:03:45 +07:00
parent 0a080b09e4
commit 7c2a4c0280
2 changed files with 11 additions and 1 deletions

View file

@ -112,6 +112,15 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
return data;
}
public async Task<UserDutyTime?> GetFirstInUseRound(Guid id)
{
var data = await _dbContext.Set<UserDutyTime>()
.Where(x => x.DutyTimeId == id)
.FirstOrDefaultAsync();
return data;
}
#endregion
}

View file

@ -277,7 +277,8 @@ namespace BMA.EHR.Leave.Service.Controllers
}
else
{
if (oldData.IsActive || oldData.IsDefault)
var inUseRound = _userDutyTimeRepository.GetFirstInUseRound(oldData.Id);
if (inUseRound != null || oldData.IsActive || oldData.IsDefault)
{
throw new Exception("ไม่สามารถลบรอบการปฏิบัติงานที่ยังใช้งานอยู่ได้");
}