From 3d7313ede7eb7cdadc78439137472935eeced718 Mon Sep 17 00:00:00 2001 From: Suphonchai Phoonsawat Date: Thu, 14 Dec 2023 09:11:37 +0700 Subject: [PATCH] =?UTF-8?q?fix=20Defect=20LV2=5F003=20-=20=E0=B9=80?= =?UTF-8?q?=E0=B8=8A=E0=B9=87=E0=B8=84=E0=B8=81=E0=B8=B2=E0=B8=A3=E0=B8=A2?= =?UTF-8?q?=E0=B8=B7=E0=B9=88=E0=B8=99=E0=B8=82=E0=B8=AD=E0=B8=A5=E0=B8=B2?= =?UTF-8?q?=20(USER)=5Fdefect=5F001#188=20LV2=5F013=20-=20=E0=B9=80?= =?UTF-8?q?=E0=B8=88=E0=B9=89=E0=B8=B2=E0=B8=AB=E0=B8=99=E0=B9=89=E0=B8=B2?= =?UTF-8?q?=E0=B8=97=E0=B8=B5=E0=B9=88=E0=B8=AD=E0=B8=99=E0=B8=B8=E0=B8=A1?= =?UTF-8?q?=E0=B8=B1=E0=B8=95=E0=B8=B4=E0=B8=81=E0=B8=B2=E0=B8=A3=E0=B8=A5?= =?UTF-8?q?=E0=B8=B2=20(ADMIN)=5Fdefect=5F001#189?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LeaveRequests/LeaveRequestRepository.cs | 17 ++++++++++++----- BMA.EHR.Domain/Extensions/DateTimeExtension.cs | 2 +- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/BMA.EHR.Application/Repositories/Leaves/LeaveRequests/LeaveRequestRepository.cs b/BMA.EHR.Application/Repositories/Leaves/LeaveRequests/LeaveRequestRepository.cs index beb582d0..74821d20 100644 --- a/BMA.EHR.Application/Repositories/Leaves/LeaveRequests/LeaveRequestRepository.cs +++ b/BMA.EHR.Application/Repositories/Leaves/LeaveRequests/LeaveRequestRepository.cs @@ -79,10 +79,17 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests public override async Task UpdateAsync(LeaveRequest entity) { - _dbContext.Attatch(entity.LeaveCancelDocument); - _dbContext.Attatch(entity.LeaveDraftDocument); - _dbContext.Attatch(entity.LeaveDocument); - _dbContext.Attatch(entity.Type); + if (entity.LeaveCancelDocument != null) + _dbContext.Attatch(entity.LeaveCancelDocument); + + if (entity.LeaveDraftDocument != null) + _dbContext.Attatch(entity.LeaveDraftDocument); + + if (entity.LeaveDocument != null) + _dbContext.Attatch(entity.LeaveDocument); + + if (entity.Type != null) + _dbContext.Attatch(entity.Type); return await base.UpdateAsync(entity); } @@ -301,7 +308,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests throw new Exception(GlobalMessages.DataNotFound); } - if (rawData.ApproveStep != "st1") + if (rawData.ApproveStep != "st2") { throw new Exception("คำขอนี้ยังไม่ได้รับการอนุมัติจากเจ้าหน้าที่ ไม่สามารถทำรายการได้"); } diff --git a/BMA.EHR.Domain/Extensions/DateTimeExtension.cs b/BMA.EHR.Domain/Extensions/DateTimeExtension.cs index e5bc7a18..985327de 100644 --- a/BMA.EHR.Domain/Extensions/DateTimeExtension.cs +++ b/BMA.EHR.Domain/Extensions/DateTimeExtension.cs @@ -18,7 +18,7 @@ namespace BMA.EHR.Domain.Extensions { throw new ArgumentException("End Date must greater than start date."); } - return (int)(endDate.Date - startDate.Date).TotalDays; + return (int)(endDate.Date - startDate.Date).TotalDays + 1; } public static double DiffYear(this DateTime currentDate)