Merge branch 'develop'
This commit is contained in:
commit
19c47af515
1 changed files with 46 additions and 60 deletions
|
|
@ -502,46 +502,35 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
LastUpdateUserId = UserId ?? "",
|
LastUpdateUserId = UserId ?? "",
|
||||||
LastUpdatedAt = DateTime.Now,
|
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;
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||||
int chkDigit = 11 - calStp2;
|
|
||||||
|
|
||||||
//////if (chkDigit == 10)
|
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||||
//////{
|
|
||||||
////// chkDigit = 1;
|
var _res = await client.PostAsJsonAsync(apiUrlCheckCitizen, new
|
||||||
//////}
|
|
||||||
//////else if (chkDigit == 11)
|
{
|
||||||
//////{
|
|
||||||
////// chkDigit = chkDigit % 10;
|
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 avatarUrl = string.Empty;
|
||||||
var apiUrl = $"{_configuration["API"]}/org/profile/citizenid/position/{req.citizenId}";
|
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);
|
.FirstOrDefaultAsync(x => x.Id == id);
|
||||||
if (uppdated == null)
|
if (uppdated == null)
|
||||||
return Error(GlobalMessages.PlacementReceiveNotFound, 404);
|
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;
|
var apiUrlCheckCitizen = $"{_configuration["API"]}/org/dotnet/check-citizen";
|
||||||
int chkDigit = 11 - calStp2;
|
|
||||||
|
|
||||||
if (chkDigit >= 10)
|
using (var client = new HttpClient())
|
||||||
{
|
|
||||||
chkDigit = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
uppdated.Relationship = req.Relationship;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue