แก้ไข เวลาเปลี่ยนรอบเป็น isactive = false ให้ไปลบรายการที่เคยเอาไปผูกกับ user ด้วย
This commit is contained in:
parent
c0f4cd3bdf
commit
55f0dc6876
1 changed files with 8 additions and 0 deletions
|
|
@ -322,6 +322,14 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
oldData.IsDefault = data.IsDefault;
|
oldData.IsDefault = data.IsDefault;
|
||||||
oldData.IsActive = data.IsActive;
|
oldData.IsActive = data.IsActive;
|
||||||
|
|
||||||
|
if (!data.IsActive)
|
||||||
|
{
|
||||||
|
// ลบรายการที่เคยผูกไว้ทั้งหมด
|
||||||
|
var userDutyTimes = await _context.UserDutyTimes.Where(x => x.DutyTimeId == oldData.Id).ToListAsync();
|
||||||
|
_context.UserDutyTimes.RemoveRange(userDutyTimes);
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
|
||||||
await _dutyTimeRepository.UpdateAsync(oldData);
|
await _dutyTimeRepository.UpdateAsync(oldData);
|
||||||
|
|
||||||
return Success(oldData);
|
return Success(oldData);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue