Merge branch 'develop' into dev
All checks were successful
Build & Deploy on Dev / build (push) Successful in 39s
All checks were successful
Build & Deploy on Dev / build (push) Successful in 39s
This commit is contained in:
commit
6089ee4979
2 changed files with 23 additions and 51 deletions
|
|
@ -1559,12 +1559,12 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// โหลดใบชำระเงิน
|
||||
/// กรอกเลขประจำตัวประชาชน
|
||||
/// </summary>
|
||||
/// <param name="examId">รหัสรอบสมัคร</param>
|
||||
/// <param name="positionId">Id ตำแหน่งสมัครสอบ</param>
|
||||
/// <returns></returns>
|
||||
/// <response code="200">เมื่อทำการโหลดใบชำระเงิน สำเร็จ</response>
|
||||
/// <response code="200">เมื่อกรอกเลขประจำตัวประชาชน สำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPut("check/citizen/{examId:length(36)}/{positionId:length(36)}")]
|
||||
|
|
|
|||
|
|
@ -2600,64 +2600,42 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
|
||||
public async Task CheckCitizen(string examId, string positionId, string citizenId)
|
||||
{
|
||||
// เช็ครอบสมัครสอบ
|
||||
var exam = await _context.PeriodExams.AsQueryable()
|
||||
.Where(p => p.CheckDisability == false)
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(examId));
|
||||
|
||||
if (exam == null)
|
||||
throw new Exception(GlobalMessages.ExamNotFound);
|
||||
|
||||
#region check digit (old)
|
||||
// if (citizenId.Length != 13)
|
||||
// throw new Exception(GlobalMessages.CitizenIncomplete);
|
||||
|
||||
// int[] citizenIdDigits = 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;
|
||||
|
||||
// if (chkDigit >= 10)
|
||||
// {
|
||||
// chkDigit = 0;
|
||||
// }
|
||||
|
||||
// if (citizenIdDigits[12] != chkDigit)
|
||||
// throw new Exception(GlobalMessages.CitizenIncorrect);
|
||||
#endregion
|
||||
|
||||
// เช็คตำแหน่งที่สมัครสอบ
|
||||
if (positionId != "00000000-0000-0000-0000-000000000000")
|
||||
{
|
||||
var position = await _context.PositionExams.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(positionId) && x.PeriodExam == exam);
|
||||
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(positionId) && x.PeriodExam == exam);
|
||||
if (position == null)
|
||||
throw new Exception(GlobalMessages.PositionExamNotFound);
|
||||
}
|
||||
|
||||
// เช็คเลขบัตรซ้ำ
|
||||
var candidate = await _context.Candidates.AsQueryable()
|
||||
.Where(x =>
|
||||
x.PeriodExam == exam
|
||||
&& x.UserId != UserId
|
||||
&& x.CitizenId == citizenId
|
||||
&& (
|
||||
(exam.Fee > 0 && x.Status.Trim().ToUpper() != "REGISTER")
|
||||
|| (exam.Fee == 0 && x.Status.Trim().ToUpper() == "CHECKSEAT")
|
||||
)
|
||||
)
|
||||
.FirstOrDefaultAsync();
|
||||
if (candidate != null)
|
||||
throw new Exception(GlobalMessages.CitizanDupicate);
|
||||
|
||||
//var candidate1 = await _context.Candidates.AsQueryable()
|
||||
// .Where(x => x.PeriodExam == exam && x.UserId != UserId /*&& x.PositionExam == position*/ && x.CitizenId == citizenId)
|
||||
// .FirstOrDefaultAsync();
|
||||
//if (candidate1 != null)
|
||||
// throw new Exception(GlobalMessages.CitizanDupicate);
|
||||
//return;
|
||||
}
|
||||
|
||||
// เช็ค Digit เลขบัตร
|
||||
var apiUrl = $"{_configuration["API"]}/org/dotnet/check-citizen";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token?.Replace("Bearer ", ""));
|
||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
var _res = await client.PostAsJsonAsync(apiUrl, new
|
||||
{
|
||||
|
|
@ -2669,12 +2647,6 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
throw new Exception(jsonData?["message"]?.ToString());
|
||||
}
|
||||
|
||||
var candidate2 = await _context.Candidates.AsQueryable()
|
||||
.Where(x => x.PeriodExam == exam && x.UserId != UserId && x.CitizenId == citizenId)
|
||||
.FirstOrDefaultAsync();
|
||||
if (candidate2 != null)
|
||||
throw new Exception(GlobalMessages.CitizanDupicate);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue