Merge branch 'develop' into adiDev
All checks were successful
Build & Deploy Placement Service / build (push) Successful in 1m42s
All checks were successful
Build & Deploy Placement Service / build (push) Successful in 1m42s
This commit is contained in:
commit
ce4558c240
1 changed files with 26 additions and 1 deletions
|
|
@ -2198,8 +2198,11 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
[HttpPost("candidate/report/excecute")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportExecuteCandidate([FromBody] ReportExecuteRequest req)
|
||||
{
|
||||
Console.WriteLine($"[CandidateReportExcecute] Starting execution at {DateTime.Now}");
|
||||
|
||||
try
|
||||
{
|
||||
Console.WriteLine($"[CandidateReportExcecute] Request received with {req?.refIds?.Length ?? 0} refIds");
|
||||
var placementProfile = await _context.PlacementProfiles
|
||||
.Include(x => x.PlacementCertificates)
|
||||
.Include(x => x.PlacementEducations)
|
||||
|
|
@ -2207,8 +2210,15 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
||||
.ToListAsync();
|
||||
|
||||
Console.WriteLine($"[CandidateReportExcecute] Found {placementProfile?.Count ?? 0} placement profiles");
|
||||
|
||||
if (placementProfile == null)
|
||||
{
|
||||
Console.Error.WriteLine("[CandidateReportExcecute] PlacementProfile is null - returning NotFound");
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Console.WriteLine("[CandidateReportExcecute] Building resultData from placement profiles and refIds");
|
||||
|
||||
var resultData = (from p in placementProfile
|
||||
join r in req.refIds
|
||||
|
|
@ -2366,6 +2376,9 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
},
|
||||
}).ToList();
|
||||
|
||||
Console.WriteLine($"[CandidateReportExcecute] resultData built successfully with {resultData?.Count ?? 0} records");
|
||||
|
||||
Console.WriteLine($"[CandidateReportExcecute] Calling external API: {_configuration["API"]}/org/command/excexute/create-officer-profile");
|
||||
var apiUrl = $"{_configuration["API"]}/org/command/excexute/create-officer-profile";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
|
|
@ -2377,8 +2390,10 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
data = resultData
|
||||
});
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
Console.WriteLine($"[CandidateReportExcecute] External API response status: {_res.StatusCode}");
|
||||
if (_res.IsSuccessStatusCode)
|
||||
{
|
||||
Console.WriteLine("[CandidateReportExcecute] External API call successful - updating placement profiles");
|
||||
placementProfile.ForEach(profile =>
|
||||
{
|
||||
profile.PlacementStatus = "DONE";
|
||||
|
|
@ -2392,17 +2407,27 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
profile.templateDoc = req.refIds[0].remark;
|
||||
}
|
||||
});
|
||||
Console.WriteLine($"[CandidateReportExcecute] Saving changes to database for {placementProfile.Count} profiles");
|
||||
await _context.SaveChangesAsync();
|
||||
Console.WriteLine("[CandidateReportExcecute] Database save completed successfully");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.Error.WriteLine($"[CandidateReportExcecute] External API call failed with status: {_res.StatusCode}");
|
||||
Console.Error.WriteLine($"[CandidateReportExcecute] Response content: {_result}");
|
||||
}
|
||||
}
|
||||
|
||||
// // update placementstatus
|
||||
// placementProfile.ForEach(profile => profile.PlacementStatus = "DONE");
|
||||
// await _context.SaveChangesAsync();
|
||||
Console.WriteLine($"[CandidateReportExcecute] Process completed successfully at {DateTime.Now}");
|
||||
return Success();
|
||||
}
|
||||
catch
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.Error.WriteLine($"[CandidateReportExcecute] Error occurred: {ex.Message}");
|
||||
Console.Error.WriteLine($"[CandidateReportExcecute] Stack trace: {ex.StackTrace}");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue