gen commander at retirement resign

This commit is contained in:
moss 2025-05-27 20:10:19 +07:00
parent 4b43104400
commit afef4fde9f
2 changed files with 44 additions and 2 deletions

View file

@ -1203,6 +1203,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
public async Task<ActionResult<ResponseObject>> Cancel([FromBody] RetirementReasonRequest req, Guid id)
{
var updated = await _context.RetirementResigns.AsQueryable()
.Include(x => x.Approvers)
.FirstOrDefaultAsync(x => x.Id == id);
if (updated == null)
return Error(GlobalMessages.RetirementResignNotFound, 404);
@ -1282,6 +1283,27 @@ namespace BMA.EHR.Retirement.Service.Controllers
};
await _context.RetirementResignCancels.AddAsync(retirementResignCancel);
await _context.SaveChangesAsync();
var addList = new List<RetirementResignCancelApprover>();
foreach (var r in updated.Approvers)
{
addList.Add(new RetirementResignCancelApprover
{
Seq = r.Seq,
RetirementResignCancel = retirementResignCancel,
Prefix = r.Prefix,
FirstName = r.FirstName,
LastName = r.LastName,
PositionName = r.PositionName,
ProfileId = r.ProfileId,
KeycloakId = r.KeycloakId,
Org = r.Org,
ApproveStatus = "PENDING",
ApproveType = r.ApproveType
});
}
await _context.AddRangeAsync(addList);
await _context.SaveChangesAsync();
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
@ -1304,8 +1326,6 @@ namespace BMA.EHR.Retirement.Service.Controllers
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _res = await client.DeleteAsync($"{_configuration["API"]}/org/command/tab2Cancel17/{updated.Id}");
Console.WriteLine(_res);
Console.WriteLine($"{_configuration["API"]}/org/command/tab2Cancel17/{updated.Id}");
}
updated.Status = "CANCELING";
}

View file

@ -1109,6 +1109,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
public async Task<ActionResult<ResponseObject>> Cancel([FromBody] RetirementReasonRequest req, Guid id)
{
var updated = await _context.RetirementResignEmployees.AsQueryable()
.Include(x => x.Approvers)
.FirstOrDefaultAsync(x => x.Id == id);
if (updated == null)
return Error(GlobalMessages.RetirementResignEmployeeNotFound, 404);
@ -1187,6 +1188,27 @@ namespace BMA.EHR.Retirement.Service.Controllers
};
await _context.RetirementResignEmployeeCancels.AddAsync(retirementResignEmployeeCancel);
await _context.SaveChangesAsync();
var addList = new List<RetirementResignEmployeeCancelApprover>();
foreach (var r in updated.Approvers)
{
addList.Add(new RetirementResignEmployeeCancelApprover
{
Seq = r.Seq,
RetirementResignEmployeeCancel = retirementResignEmployeeCancel,
Prefix = r.Prefix,
FirstName = r.FirstName,
LastName = r.LastName,
PositionName = r.PositionName,
ProfileId = r.ProfileId,
KeycloakId = r.KeycloakId,
Org = r.Org,
ApproveStatus = "PENDING",
ApproveType = r.ApproveType
});
}
await _context.AddRangeAsync(addList);
await _context.SaveChangesAsync();
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));