แยกประเภทขรก

This commit is contained in:
Kittapath 2024-07-03 00:42:41 +07:00
parent 54661ffbcb
commit 5751ea57a4
3 changed files with 34 additions and 2 deletions

View file

@ -246,6 +246,8 @@ namespace BMA.EHR.Domain.Models.Placement
[Comment("หมายเหตุแนวนอน")]
public string? RemarkHorizontal { get; set; }
[Comment("profileId")]
public string? profileId { get; set; }
public virtual List<PlacementCertificate> PlacementCertificates { get; set; } = new List<PlacementCertificate>();
public virtual List<PlacementEducation> PlacementEducations { get; set; } = new List<PlacementEducation>();
}

View file

@ -10,6 +10,8 @@ using BMA.EHR.MetaData.Service.Models;
using BMA.EHR.Domain.Models.Placement;
using BMA.EHR.Recurit.Service.Data;
using System.Security.Claims;
using System.Net.Http.Headers;
using Newtonsoft.Json;
namespace BMA.EHR.Recruit.Service.Services
{
@ -19,16 +21,19 @@ namespace BMA.EHR.Recruit.Service.Services
private readonly MetadataDbContext _contextMetadata;
private readonly MinIOService _minIOService;
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly IConfiguration _configuration;
public RecruitService(ApplicationDbContext context,
MetadataDbContext contextMetadata,
IHttpContextAccessor httpContextAccessor,
MinIOService minIOService)
MinIOService minIOService,
IConfiguration configuration)
{
_context = context;
_contextMetadata = contextMetadata;
_minIOService = minIOService;
_httpContextAccessor = httpContextAccessor;
_configuration = configuration;
}
#region " Properties "
@ -36,6 +41,7 @@ namespace BMA.EHR.Recruit.Service.Services
private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
private string? token => _httpContextAccessor?.HttpContext?.Request.Headers["Authorization"];
#endregion
@ -204,6 +210,27 @@ namespace BMA.EHR.Recruit.Service.Services
.ToListAsync();
foreach (var candidate in candidates)
{
var IsOfficer = false;
dynamic org = null;
var apiUrl = $"{_configuration["API"]}org/profile/citizenid/position/{candidate.CitizenId}";
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var _res = await client.SendAsync(_req);
var _result = await _res.Content.ReadAsStringAsync();
org = JsonConvert.DeserializeObject<dynamic>(_result);
if (org == null || org.result == null)
{
IsOfficer = false;
}
else
{
IsOfficer = true;
}
}
var Address = candidate.Addresses.FirstOrDefault() == null ? null : $"{candidate.Addresses.FirstOrDefault().Address}";
var Moo = candidate.Addresses.FirstOrDefault() == null ? null : $" หมู่ {candidate.Addresses.FirstOrDefault().Moo}";
var Soi = candidate.Addresses.FirstOrDefault() == null ? null : $" ซอย {candidate.Addresses.FirstOrDefault().Soi}";
@ -308,6 +335,8 @@ namespace BMA.EHR.Recruit.Service.Services
LastUpdatedAt = DateTime.Now,
LastUpdateUserId = UserId ?? "",
LastUpdateFullName = FullName ?? "",
IsOfficer = IsOfficer,
profileId = org == null || org.result == null ? null : org.result.profileId,
};
await _contextMetadata.PlacementProfiles.AddAsync(placementProfile);

View file

@ -31,5 +31,6 @@
"AccessKey": "ZQOGEjHxDesiVIHR",
"SecretKey": "vKTpcxY0Wjjp775aDwNn1q6VWJu8EFb6",
"BucketName": "bma-recruit"
}
},
"API": "https://bma-ehr.frappet.synology.me/api/v1/"
}