From 77eaca72b3b322e2fdd68fc46c74804f4b8420aa Mon Sep 17 00:00:00 2001 From: kittapath <> Date: Thu, 25 Sep 2025 02:30:33 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=AD=E0=B8=AD=E0=B8=81=E0=B8=84=E0=B8=B3?= =?UTF-8?q?=E0=B8=AA=E0=B8=B1=E0=B9=88=E0=B8=87=E0=B8=A2=E0=B8=81=E0=B9=80?= =?UTF-8?q?=E0=B8=A5=E0=B8=B4=E0=B8=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/RetirementResignController.cs | 58 ++++++++++++------ .../RetirementResignEmployeeController.cs | 59 +++++++++++++------ 2 files changed, 83 insertions(+), 34 deletions(-) diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs index 5030559a..d8f2adf0 100644 --- a/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs +++ b/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs @@ -3050,27 +3050,51 @@ namespace BMA.EHR.Retirement.Service.Controllers }).ToList(); var baseAPIOrg = _configuration["API"]; - var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave"; - using (var client = new HttpClient()) + var reportDone = false; + if (data.Where(profile => profile.Status == "DONE").Any()) { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _res = await client.PostAsJsonAsync(apiUrlOrg, new + reportDone = true; + } + if (reportDone == true) + { + var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave"; + using (var client = new HttpClient()) { - data = resultData, - }); - var _result = await _res.Content.ReadAsStringAsync(); - if (_res.IsSuccessStatusCode) - { - data.ForEach(profile => profile.Status = "DONE"); - data.ForEach(profile => profile.RetirementResign.Status = "CANCEL"); - // var _data = await _context.RetirementResigns - // .Where(x => data.Select(x => x.RetirementResign.Id).Contains(x.Id)) - // .ToListAsync(); - // _data.ForEach(profile => profile.Status = "DONEREJECT"); - await _context.SaveChangesAsync(); + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _res = await client.PostAsJsonAsync(apiUrlOrg, new + { + data = resultData, + }); + var _result = await _res.Content.ReadAsStringAsync(); + if (_res.IsSuccessStatusCode) + { + data.ForEach(profile => profile.Status = "DONE"); + data.ForEach(profile => profile.RetirementResign.Status = "CANCEL"); + await _context.SaveChangesAsync(); + } } } + else + { + // var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave"; + // using (var client = new HttpClient()) + // { + // client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + // client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + // var _res = await client.PostAsJsonAsync(apiUrlOrg, new + // { + // data = resultData, + // }); + // var _result = await _res.Content.ReadAsStringAsync(); + // if (_res.IsSuccessStatusCode) + // { + data.ForEach(profile => profile.Status = "DONE"); + data.ForEach(profile => profile.RetirementResign.Status = "CANCEL"); + await _context.SaveChangesAsync(); + // } + // } + } return Success(); } diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementResignEmployeeController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementResignEmployeeController.cs index 8a842aea..8600ed2e 100644 --- a/BMA.EHR.Retirement.Service/Controllers/RetirementResignEmployeeController.cs +++ b/BMA.EHR.Retirement.Service/Controllers/RetirementResignEmployeeController.cs @@ -2545,27 +2545,52 @@ namespace BMA.EHR.Retirement.Service.Controllers }).ToList(); var baseAPIOrg = _configuration["API"]; - var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-employee-leave"; - using (var client = new HttpClient()) + var reportDone = false; + if (data.Where(profile => profile.Status == "DONE").Any()) { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _res = await client.PostAsJsonAsync(apiUrlOrg, new + reportDone = true; + } + + if (reportDone == true) + { + var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-employee-leave"; + using (var client = new HttpClient()) { - data = resultData, - }); - var _result = await _res.Content.ReadAsStringAsync(); - if (_res.IsSuccessStatusCode) - { - data.ForEach(profile => profile.Status = "DONE"); - data.ForEach(profile => profile.RetirementResignEmployee.Status = "CANCEL"); - // var _data = await _context.RetirementResignEmployees - // .Where(x => data.Select(x => x.RetirementResignEmployee.Id).Contains(x.Id)) - // .ToListAsync(); - // _data.ForEach(profile => profile.Status = "DONEREJECT"); - await _context.SaveChangesAsync(); + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _res = await client.PostAsJsonAsync(apiUrlOrg, new + { + data = resultData, + }); + var _result = await _res.Content.ReadAsStringAsync(); + if (_res.IsSuccessStatusCode) + { + data.ForEach(profile => profile.Status = "DONE"); + data.ForEach(profile => profile.RetirementResignEmployee.Status = "CANCEL"); + await _context.SaveChangesAsync(); + } } } + else + { + // var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-employee-leave"; + // using (var client = new HttpClient()) + // { + // client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + // client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + // var _res = await client.PostAsJsonAsync(apiUrlOrg, new + // { + // data = resultData, + // }); + // var _result = await _res.Content.ReadAsStringAsync(); + // if (_res.IsSuccessStatusCode) + // { + data.ForEach(profile => profile.Status = "DONE"); + data.ForEach(profile => profile.RetirementResignEmployee.Status = "CANCEL"); + await _context.SaveChangesAsync(); + // } + // } + } return Success(); }