From 5065ad326984800b7f63382f400feab1b132679d Mon Sep 17 00:00:00 2001 From: Kittapath Date: Tue, 24 Oct 2023 18:52:49 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=A2=E0=B8=B7=E0=B8=A1=20=E0=B8=84?= =?UTF-8?q?=E0=B8=B7=E0=B8=99=20=E0=B8=AA=E0=B8=B3=E0=B8=99=E0=B8=B1?= =?UTF-8?q?=E0=B8=81=E0=B8=95=E0=B8=B1=E0=B8=A7=E0=B9=80=E0=B8=AD=E0=B8=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Requests/InsigniaBorrowRequest.cs | 2 +- .../Controllers/InsigniaManageController.cs | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/BMA.EHR.Application/Requests/InsigniaBorrowRequest.cs b/BMA.EHR.Application/Requests/InsigniaBorrowRequest.cs index 65b80dae..3d8481a6 100644 --- a/BMA.EHR.Application/Requests/InsigniaBorrowRequest.cs +++ b/BMA.EHR.Application/Requests/InsigniaBorrowRequest.cs @@ -6,7 +6,7 @@ namespace BMA.EHR.Application.Requests public class InsigniaBorrowRequest { public DateTime BorrowDate { get; set; } - public Guid BorrowOrganizationId { get; set; } + public Guid? BorrowOrganizationId { get; set; } public Guid InsigniaNoteProfileId { get; set; } } } diff --git a/BMA.EHR.Insignia.Service/Controllers/InsigniaManageController.cs b/BMA.EHR.Insignia.Service/Controllers/InsigniaManageController.cs index 742c47a2..d7ce8714 100644 --- a/BMA.EHR.Insignia.Service/Controllers/InsigniaManageController.cs +++ b/BMA.EHR.Insignia.Service/Controllers/InsigniaManageController.cs @@ -406,7 +406,7 @@ namespace BMA.EHR.Insignia.Service.Controllers } /// - /// แก้ไขยืมเครื่องราชฯ + /// ยืมเครื่องราชฯ /// /// /// @@ -416,11 +416,6 @@ namespace BMA.EHR.Insignia.Service.Controllers [HttpPost("borrow")] public async Task> PostBorrowInsignia([FromBody] InsigniaBorrowRequest req) { - var organization = await _context.Organizations.AsQueryable() - .Include(x => x.OrganizationOrganization) - .FirstOrDefaultAsync(x => x.Id == req.BorrowOrganizationId); - if (organization == null) - return Error(GlobalMessages.OrganizationNotFound); var insigniaNoteProfile = await _context.InsigniaNoteProfiles.AsQueryable() .Include(x => x.RequestInsignia) @@ -431,6 +426,12 @@ namespace BMA.EHR.Insignia.Service.Controllers if (insigniaNoteProfile.Status != "DONE") return Error(GlobalMessages.InsigniaNoBorrow); + var organization = await _context.Organizations.AsQueryable() + .Include(x => x.OrganizationOrganization) + .FirstOrDefaultAsync(x => x.Id == insigniaNoteProfile.Profile.OcId); + if (organization == null) + return Error(GlobalMessages.OrganizationNotFound); + var insigniaManage = await _context.InsigniaManages.AsQueryable() .FirstOrDefaultAsync(x => x.Year == insigniaNoteProfile.InsigniaNote.Year && x.Insignia == insigniaNoteProfile.RequestInsignia); if (insigniaManage == null) @@ -472,7 +473,7 @@ namespace BMA.EHR.Insignia.Service.Controllers } /// - /// แก้ไขคืนเครื่องราชฯ + /// คืนเครื่องราชฯ /// /// Id ยืมเครื่องราช ///