แก้ไข เวลาเปลี่ยนรอบเป็น isactive = false ให้ไปลบรายการที่เคยเอาไปผูกกับ user ด้วย

This commit is contained in:
Suphonchai Phoonsawat 2025-10-20 15:12:01 +07:00
parent c0f4cd3bdf
commit 55f0dc6876

View file

@ -322,6 +322,14 @@ namespace BMA.EHR.Leave.Service.Controllers
oldData.IsDefault = data.IsDefault;
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);
return Success(oldData);