diff --git a/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs b/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs index 2363f19f..025c78c1 100644 --- a/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs +++ b/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs @@ -754,67 +754,33 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน [HttpPost("command25/report")] - public async Task> PostReportCommand25([FromBody] ReportPersonRequest req_) + public async Task> PostReportCommand25([FromBody] ReportPersonRequest req) { try { - var resultData = new List(); - var baseAPI = _configuration["API"]; + // var resultData = new List(); + // var baseAPI = _configuration["API"]; - foreach (var id in req_.refIds) - { - var apiUrl = $"{baseAPI}/discipline/result/report/stop/{id}"; - var commandType = await _context.Set() - .Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-25") - .FirstOrDefaultAsync(); - var response = new PassDisciplineResponse(); - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var req = new HttpRequestMessage(HttpMethod.Get, apiUrl); - var res = await client.SendAsync(req); - var result = await res.Content.ReadAsStringAsync(); + // foreach (var id in req_.refIds) + // { + // var apiUrl = $"{baseAPI}/discipline/result/report/stop/{id}"; - response = JsonConvert.DeserializeObject(result); - - var seq = 1; - foreach (var d in response!.result) - { - if (commandType == null || commandType.Id != d.commandId) - continue; - var _baseAPI = _configuration["API"]; - var _apiUrl = $"{_baseAPI}/org/profile/profileid/position/{d.personId}"; - using (var _client = new HttpClient()) - { - _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl); - var _res = await _client.SendAsync(_req); - var _result = await _res.Content.ReadAsStringAsync(); - - var org = JsonConvert.DeserializeObject(_result); - - if (org == null || org.result == null) - continue; - - var receiver = new CommandReceiver - { - Sequence = seq, - CitizenId = org.result.citizenId == null ? "" : org.result.citizenId, - Prefix = org.result.prefix == null ? "" : org.result.prefix, - FirstName = org.result.firstName == null ? "" : org.result.firstName, - LastName = org.result.lastName == null ? "" : org.result.lastName, - RefPlacementProfileId = org.result.profileId == null ? null : Guid.Parse(org.result.profileId), - RefDisciplineId = d.id, - Amount = 0, - }; - seq++; - resultData.Add(receiver); - } - } - } - } + // } + // var data = await _context.DisciplineReport_Profiles + // .Where(x => x.Status == "REPORT") + // .Where(x => x.DisciplineDisciplinary.DisciplineInvestigate.DisciplineComplaint.Id == id) + // .Select(x => new + // { + // PersonId = x.PersonId, + // Id = x.Id, + // CommandId = x.CommandTypeId, + // }) + // .ToListAsync(); + var data = await _context.DisciplineReport_Profiles + .Where(x => req.refIds.Contains(x.Id.ToString())) + .ToListAsync(); + data.ForEach(profile => profile.Status = "REPORT"); + await _context.SaveChangesAsync(); return Success(); } catch