This commit is contained in:
parent
cc8cd77560
commit
d6497a5d51
1 changed files with 46 additions and 60 deletions
|
|
@ -502,46 +502,35 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
LastUpdateUserId = UserId ?? "",
|
||||
LastUpdatedAt = DateTime.Now,
|
||||
};
|
||||
if (placementReceive.citizenId.Length != 13)
|
||||
|
||||
var apiUrlCheckCitizen = $"{_configuration["API"]}/org/dotnet/check-citizen";
|
||||
|
||||
using (var client = new HttpClient())
|
||||
|
||||
{
|
||||
return Error("กรุณากรอกข้อมูลรหัสบัตรประจำตัวประชาชนให้ครบ 13 หลัก", 500);
|
||||
}
|
||||
int[] citizenIdDigits = placementReceive.citizenId.Select(c => int.Parse(c.ToString())).ToArray();
|
||||
int cal =
|
||||
citizenIdDigits[0] * 13 +
|
||||
citizenIdDigits[1] * 12 +
|
||||
citizenIdDigits[2] * 11 +
|
||||
citizenIdDigits[3] * 10 +
|
||||
citizenIdDigits[4] * 9 +
|
||||
citizenIdDigits[5] * 8 +
|
||||
citizenIdDigits[6] * 7 +
|
||||
citizenIdDigits[7] * 6 +
|
||||
citizenIdDigits[8] * 5 +
|
||||
citizenIdDigits[9] * 4 +
|
||||
citizenIdDigits[10] * 3 +
|
||||
citizenIdDigits[11] * 2;
|
||||
|
||||
int calStp2 = cal % 11;
|
||||
int chkDigit = 11 - calStp2;
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
|
||||
//////if (chkDigit == 10)
|
||||
//////{
|
||||
////// chkDigit = 1;
|
||||
//////}
|
||||
//////else if (chkDigit == 11)
|
||||
//////{
|
||||
////// chkDigit = chkDigit % 10;
|
||||
//////}
|
||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
|
||||
var _res = await client.PostAsJsonAsync(apiUrlCheckCitizen, new
|
||||
|
||||
{
|
||||
|
||||
placementReceive.citizenId
|
||||
|
||||
});
|
||||
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
|
||||
var jsonDataCheckCitizen = JsonConvert.DeserializeObject<JObject>(_result);
|
||||
|
||||
if (!_res.IsSuccessStatusCode)
|
||||
|
||||
throw new Exception(jsonDataCheckCitizen?["message"]?.ToString());
|
||||
|
||||
if (chkDigit >= 10)
|
||||
{
|
||||
chkDigit = 0;
|
||||
}
|
||||
|
||||
if (citizenIdDigits[12] != chkDigit)
|
||||
{
|
||||
return Error("ข้อมูลรหัสบัตรประจำตัวประชาชนไม่ถูกต้อง", 500);
|
||||
}
|
||||
|
||||
var avatarUrl = string.Empty;
|
||||
var apiUrl = $"{_configuration["API"]}/org/profile/citizenid/position/{req.citizenId}";
|
||||
|
|
@ -823,36 +812,33 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
.FirstOrDefaultAsync(x => x.Id == id);
|
||||
if (uppdated == null)
|
||||
return Error(GlobalMessages.PlacementReceiveNotFound, 404);
|
||||
if (req.citizenId.Length != 13)
|
||||
{
|
||||
return Error("กรุณากรอกข้อมูลรหัสบัตรประจำตัวประชาชนให้ครบ 13 หลัก", 500);
|
||||
}
|
||||
int[] citizenIdDigits = req.citizenId.Select(c => int.Parse(c.ToString())).ToArray();
|
||||
int cal =
|
||||
citizenIdDigits[0] * 13 +
|
||||
citizenIdDigits[1] * 12 +
|
||||
citizenIdDigits[2] * 11 +
|
||||
citizenIdDigits[3] * 10 +
|
||||
citizenIdDigits[4] * 9 +
|
||||
citizenIdDigits[5] * 8 +
|
||||
citizenIdDigits[6] * 7 +
|
||||
citizenIdDigits[7] * 6 +
|
||||
citizenIdDigits[8] * 5 +
|
||||
citizenIdDigits[9] * 4 +
|
||||
citizenIdDigits[10] * 3 +
|
||||
citizenIdDigits[11] * 2;
|
||||
|
||||
int calStp2 = cal % 11;
|
||||
int chkDigit = 11 - calStp2;
|
||||
var apiUrlCheckCitizen = $"{_configuration["API"]}/org/dotnet/check-citizen";
|
||||
|
||||
if (chkDigit >= 10)
|
||||
{
|
||||
chkDigit = 0;
|
||||
}
|
||||
using (var client = new HttpClient())
|
||||
|
||||
if (citizenIdDigits[12] != chkDigit)
|
||||
{
|
||||
return Error("ข้อมูลรหัสบัตรประจำตัวประชาชนไม่ถูกต้อง", 500);
|
||||
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
|
||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
|
||||
var _res = await client.PostAsJsonAsync(apiUrlCheckCitizen, new
|
||||
|
||||
{
|
||||
|
||||
req.citizenId
|
||||
|
||||
});
|
||||
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
|
||||
var jsonDataCheckCitizen = JsonConvert.DeserializeObject<JObject>(_result);
|
||||
|
||||
if (!_res.IsSuccessStatusCode)
|
||||
|
||||
throw new Exception(jsonDataCheckCitizen?["message"]?.ToString());
|
||||
|
||||
}
|
||||
|
||||
uppdated.Relationship = req.Relationship;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue