refid ส่งกลับ

This commit is contained in:
moss 2025-04-01 11:08:27 +07:00
parent b1d198133f
commit 6dd057516f
5 changed files with 20143 additions and 1 deletions

View file

@ -221,7 +221,7 @@ namespace BMA.EHR.Placement.Service.Controllers
[HttpPost()]
public async Task<ActionResult<ResponseObject>> Post([FromForm] PlacementAddProfileRequest req)
{
var placementOfficer = await _context.PlacementOfficers
.Where(x => x.Id == (req.OfficerId ?? Guid.Parse("00000000-0000-0000-0000-000000000000")))
.FirstOrDefaultAsync();
@ -230,6 +230,7 @@ namespace BMA.EHR.Placement.Service.Controllers
var placementRepatriation = new PlacementRepatriation
{
Organization = placementOfficer.Organization,
refId = req.OfficerId ?? Guid.Parse("00000000-0000-0000-0000-000000000000"),
// Reason = placementOfficer.Reason,
Date = placementOfficer.DateStart,
DateRepatriation = placementOfficer.DateEnd,
@ -298,6 +299,20 @@ namespace BMA.EHR.Placement.Service.Controllers
(org.result.root == null ? "" : org.result.root);
placementRepatriation.OrganizationPositionOld = org.result.position + "\n" + (placementRepatriation.PositionExecutiveOld == null ? "" : placementRepatriation.PositionExecutiveOld + "\n") + placementRepatriation.OrganizationOld;
}
var baseAPIOrg = _configuration["API"];
var apiUrlOrg = $"{baseAPIOrg}/org/profile/assistance/status";
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
{
refId = req.OfficerId ?? Guid.Parse("00000000-0000-0000-0000-000000000000"),
status = "DONE"
});
var _result = await _res.Content.ReadAsStringAsync();
}
await _context.PlacementRepatriations.AddAsync(placementRepatriation);
await _context.SaveChangesAsync();
@ -391,6 +406,20 @@ namespace BMA.EHR.Placement.Service.Controllers
.FirstOrDefaultAsync(x => x.Id == id);
if (deleted == null)
return NotFound();
var baseAPIOrg = _configuration["API"];
var apiUrlOrg = $"{baseAPIOrg}/org/profile/assistance/status";
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
{
refId = deleted.refId ?? Guid.Parse("00000000-0000-0000-0000-000000000000"),
status = "PENDING"
});
var _result = await _res.Content.ReadAsStringAsync();
}
_context.PlacementRepatriations.Remove(deleted);
await _context.SaveChangesAsync();