From 55f0dc6876dc9c9b5eb653893a7c8363d5eed914 Mon Sep 17 00:00:00 2001 From: Suphonchai Phoonsawat Date: Mon, 20 Oct 2025 15:12:01 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=E0=B9=84=E0=B8=82?= =?UTF-8?q?=20=E0=B9=80=E0=B8=A7=E0=B8=A5=E0=B8=B2=E0=B9=80=E0=B8=9B?= =?UTF-8?q?=E0=B8=A5=E0=B8=B5=E0=B9=88=E0=B8=A2=E0=B8=99=E0=B8=A3=E0=B8=AD?= =?UTF-8?q?=E0=B8=9A=E0=B9=80=E0=B8=9B=E0=B9=87=E0=B8=99=20isactive=20=3D?= =?UTF-8?q?=20false=20=E0=B9=83=E0=B8=AB=E0=B9=89=E0=B9=84=E0=B8=9B?= =?UTF-8?q?=E0=B8=A5=E0=B8=9A=E0=B8=A3=E0=B8=B2=E0=B8=A2=E0=B8=81=E0=B8=B2?= =?UTF-8?q?=E0=B8=A3=E0=B8=97=E0=B8=B5=E0=B9=88=E0=B9=80=E0=B8=84=E0=B8=A2?= =?UTF-8?q?=E0=B9=80=E0=B8=AD=E0=B8=B2=E0=B9=84=E0=B8=9B=E0=B8=9C=E0=B8=B9?= =?UTF-8?q?=E0=B8=81=E0=B8=81=E0=B8=B1=E0=B8=9A=20user=20=E0=B8=94?= =?UTF-8?q?=E0=B9=89=E0=B8=A7=E0=B8=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BMA.EHR.Leave/Controllers/LeaveController.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/BMA.EHR.Leave/Controllers/LeaveController.cs b/BMA.EHR.Leave/Controllers/LeaveController.cs index 591c7382..89d3b401 100644 --- a/BMA.EHR.Leave/Controllers/LeaveController.cs +++ b/BMA.EHR.Leave/Controllers/LeaveController.cs @@ -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);