From 8950073485bbf0ad36b6b4c7bdf757c9bb6285ad Mon Sep 17 00:00:00 2001 From: harid Date: Fri, 3 Apr 2026 16:03:01 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=AA=E0=B9=88=E0=B8=87=E0=B8=A3=E0=B8=B2?= =?UTF-8?q?=E0=B8=A2=E0=B8=8A=E0=B8=B7=E0=B9=88=E0=B8=AD=E0=B9=84=E0=B8=9B?= =?UTF-8?q?=E0=B8=AD=E0=B8=AD=E0=B8=81=E0=B8=84=E0=B8=B3=E0=B8=AA=E0=B8=B1?= =?UTF-8?q?=E0=B9=88=E0=B8=87=20C-PM-25,=20C-PM-26=20=E0=B9=83=E0=B8=AB?= =?UTF-8?q?=E0=B9=89=E0=B8=9B=E0=B8=B1=E0=B9=8A=E0=B8=A1=20commandCode=20#?= =?UTF-8?q?2377?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/DisciplineResultController.cs | 40 ++++++++++++++++--- .../Requests/ReportPersonRequest.cs | 8 ++++ 2 files changed, 42 insertions(+), 6 deletions(-) diff --git a/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs b/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs index e5be6189..85388209 100644 --- a/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs +++ b/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs @@ -1242,14 +1242,22 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน [HttpPost("command25/report")] - public async Task> PostReportCommand25([FromBody] ReportPersonRequest req) + public async Task> PostReportCommand25([FromBody] ReportPersonAndCommandRequest req) { try { var data = await _context.DisciplineReport_Profiles .Where(x => req.refIds.Contains(x.Id.ToString())) .ToListAsync(); - data.ForEach(profile => profile.Status = req.status.Trim().ToUpper()); + // data.ForEach(profile => profile.Status = req.status.Trim().ToUpper()); + data.ForEach(profile => + { + profile.Status = !string.IsNullOrEmpty(req.status) + ? req.status.Trim().ToUpper() : null; + profile.CommandTypeId = !string.IsNullOrEmpty(req.commandTypeId) && Guid.TryParse(req.commandTypeId, out var cmdTypeId) + ? cmdTypeId : null; + profile.CommandCode = req.commandCode ?? null; + }); await _context.SaveChangesAsync(); return Success(); } @@ -1276,7 +1284,13 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers .Where(x => req.refIds.Contains(x.Id.ToString())) // .Where(x => x.Status.ToUpper() == "REPORT") .ToListAsync(); - data.ForEach(profile => profile.Status = "PENDING"); + // data.ForEach(profile => profile.Status = "PENDING"); + data.ForEach(profile => + { + profile.Status = "PENDING"; + profile.CommandTypeId = null; + profile.CommandCode = null; + }); await _context.SaveChangesAsync(); return Success(); } @@ -1429,14 +1443,22 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน [HttpPost("command26/report")] - public async Task> PostReportCommand26([FromBody] ReportPersonRequest req) + public async Task> PostReportCommand26([FromBody] ReportPersonAndCommandRequest req) { try { var data = await _context.DisciplineReport_Profiles .Where(x => req.refIds.Contains(x.Id.ToString())) .ToListAsync(); - data.ForEach(profile => profile.Status = req.status.Trim().ToUpper()); + // data.ForEach(profile => profile.Status = req.status.Trim().ToUpper()); + data.ForEach(profile => + { + profile.Status = !string.IsNullOrEmpty(req.status) + ? req.status.Trim().ToUpper() : null; + profile.CommandTypeId = !string.IsNullOrEmpty(req.commandTypeId) && Guid.TryParse(req.commandTypeId, out var cmdTypeId) + ? cmdTypeId : null; + profile.CommandCode = req.commandCode ?? null; + }); await _context.SaveChangesAsync(); return Success(); } @@ -1463,7 +1485,13 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers .Where(x => req.refIds.Contains(x.Id.ToString())) // .Where(x => x.Status.ToUpper() == "REPORT") .ToListAsync(); - data.ForEach(profile => profile.Status = "PENDING"); + // data.ForEach(profile => profile.Status = "PENDING"); + data.ForEach(profile => + { + profile.Status = "PENDING"; + profile.CommandTypeId = null; + profile.CommandCode = null; + }); await _context.SaveChangesAsync(); return Success(); } diff --git a/BMA.EHR.Discipline.Service/Requests/ReportPersonRequest.cs b/BMA.EHR.Discipline.Service/Requests/ReportPersonRequest.cs index 1bd61c56..f7a16efc 100644 --- a/BMA.EHR.Discipline.Service/Requests/ReportPersonRequest.cs +++ b/BMA.EHR.Discipline.Service/Requests/ReportPersonRequest.cs @@ -8,4 +8,12 @@ namespace BMA.EHR.Discipline.Service.Requests public string[] refIds { get; set; } public string? status { get; set; } } + + public class ReportPersonAndCommandRequest + { + public string[] refIds { get; set; } + public string? status { get; set; } + public string? commandTypeId { get; set; } + public string? commandCode { get; set; } + } }