feat: add DNA update functionality and enrich leave beginning data with profile details
Some checks failed
release-dev / release-dev (push) Failing after 12s
Some checks failed
release-dev / release-dev (push) Failing after 12s
This commit is contained in:
parent
6b9767449c
commit
fc68cb0101
2 changed files with 55 additions and 2 deletions
|
|
@ -311,6 +311,35 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
}
|
||||
}
|
||||
|
||||
[HttpGet("update-dna")]
|
||||
public async Task<ActionResult<ResponseObject>> UpdateDnaAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
var leaveBeginnings = await _context.LeaveBeginnings.ToListAsync();
|
||||
foreach (var item in leaveBeginnings)
|
||||
{
|
||||
var profile = await _userProfileRepository.GetProfileByProfileIdAsync(item.ProfileId, AccessToken);
|
||||
if (profile != null)
|
||||
{
|
||||
item.RootDnaId = profile.RootDnaId;
|
||||
item.Child1DnaId = profile.Child1DnaId;
|
||||
item.Child2DnaId = profile.Child2DnaId;
|
||||
item.Child3DnaId = profile.Child3DnaId;
|
||||
item.Child4DnaId = profile.Child4DnaId;
|
||||
_context.LeaveBeginnings.Update(item);
|
||||
}
|
||||
|
||||
}
|
||||
await _context.SaveChangesAsync();
|
||||
return Success("อัพเดทข้อมูลสำเร็จ");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Error(ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// <summary>
|
||||
/// แก้ไขรายการ
|
||||
|
|
@ -358,6 +387,12 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
leaveBeginning.LastUpdateFullName = FullName ?? "";
|
||||
leaveBeginning.LastUpdatedAt = DateTime.Now;
|
||||
|
||||
leaveBeginning.RootDnaId = profile.RootDnaId;
|
||||
leaveBeginning.Child1DnaId = profile.Child1DnaId;
|
||||
leaveBeginning.Child2DnaId = profile.Child2DnaId;
|
||||
leaveBeginning.Child3DnaId = profile.Child3DnaId;
|
||||
leaveBeginning.Child4DnaId = profile.Child4DnaId;
|
||||
|
||||
await _leaveBeginningRepository.UpdateAsync(leaveBeginning);
|
||||
return Success("แก้ไขข้อมูลสำเร็จ");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue