Linear Flow (RetirementService) #224
All checks were successful
Build & Deploy Retirement Service / build (push) Successful in 2m4s
All checks were successful
Build & Deploy Retirement Service / build (push) Successful in 2m4s
This commit is contained in:
parent
e926866918
commit
71966eb4e9
4 changed files with 213 additions and 179 deletions
|
|
@ -642,10 +642,6 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
var data = await _context.RetirementOuts
|
||||
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
||||
.ToListAsync();
|
||||
// Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
|
||||
data.ForEach(profile => profile.Status = "DONE");
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
var resultData = (from p in data
|
||||
join r in req.refIds
|
||||
on p.Id.ToString() equals r.refId
|
||||
|
|
@ -688,31 +684,39 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
resignId = p.Id,
|
||||
}).ToList();
|
||||
|
||||
var baseAPIOrg = _configuration["API"];
|
||||
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave";
|
||||
if (data.Count > 0)
|
||||
{
|
||||
if (data[0].profileType == "EMPLOYEE")
|
||||
{
|
||||
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");
|
||||
// // await _context.SaveChangesAsync();
|
||||
// // }
|
||||
}
|
||||
return Success();
|
||||
#region Old: Circular Flow
|
||||
// var baseAPIOrg = _configuration["API"];
|
||||
// var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave";
|
||||
// if (data.Count > 0)
|
||||
// {
|
||||
// if (data[0].profileType == "EMPLOYEE")
|
||||
// {
|
||||
// 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");
|
||||
// // // await _context.SaveChangesAsync();
|
||||
// // // }
|
||||
// }
|
||||
#endregion
|
||||
|
||||
// New: Linear Flow - Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
|
||||
data.ForEach(profile => profile.Status = "DONE");
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
// Return resultData for Node to process directly (Linear Flow)
|
||||
return Success(resultData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue