Merge branch 'develop' into dev
All checks were successful
Build & Deploy on Dev / build (push) Successful in 41s
All checks were successful
Build & Deploy on Dev / build (push) Successful in 41s
This commit is contained in:
commit
c82b2a622d
1 changed files with 33 additions and 8 deletions
|
|
@ -8,6 +8,9 @@ using BMA.EHR.Recurit.Exam.Service.Response;
|
|||
using BMA.EHR.Recurit.Exam.Service.Responses.Document;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using System.Net.Http.Headers;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace BMA.EHR.Recurit.Exam.Service.Services
|
||||
{
|
||||
|
|
@ -20,6 +23,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly MinIOService _minioService;
|
||||
private readonly MailService _mailService;
|
||||
private readonly IConfiguration _configuration;
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
@ -29,13 +33,15 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
OrgDbContext contextOrg,
|
||||
IHttpContextAccessor httpContextAccessor,
|
||||
MinIOService minioService,
|
||||
MailService mailService)
|
||||
MailService mailService,
|
||||
IConfiguration configuration)
|
||||
{
|
||||
_context = context;
|
||||
_contextOrg = contextOrg;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
_minioService = minioService;
|
||||
_mailService = mailService;
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
@ -43,8 +49,8 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
#region " Properties "
|
||||
|
||||
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
|
||||
|
||||
|
|
@ -2601,6 +2607,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
if (exam == null)
|
||||
throw new Exception(GlobalMessages.ExamNotFound);
|
||||
|
||||
#region check digit (old)
|
||||
// if (citizenId.Length != 13)
|
||||
// throw new Exception(GlobalMessages.CitizenIncomplete);
|
||||
|
||||
|
|
@ -2629,6 +2636,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
|
||||
// if (citizenIdDigits[12] != chkDigit)
|
||||
// throw new Exception(GlobalMessages.CitizenIncorrect);
|
||||
#endregion
|
||||
|
||||
if (positionId != "00000000-0000-0000-0000-000000000000")
|
||||
{
|
||||
|
|
@ -2638,12 +2646,27 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
if (position == null)
|
||||
throw new Exception(GlobalMessages.PositionExamNotFound);
|
||||
|
||||
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;
|
||||
//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;
|
||||
}
|
||||
|
||||
var apiUrl = $"{_configuration["API"]}/org/dotnet/check-citizen";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
var _res = await client.PostAsJsonAsync(apiUrl, new
|
||||
{
|
||||
citizenId
|
||||
});
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
var jsonData = JsonConvert.DeserializeObject<JObject>(_result);
|
||||
if (!_res.IsSuccessStatusCode)
|
||||
throw new Exception(jsonData?["message"]?.ToString());
|
||||
}
|
||||
|
||||
var candidate2 = await _context.Candidates.AsQueryable()
|
||||
|
|
@ -2651,6 +2674,8 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
.FirstOrDefaultAsync();
|
||||
if (candidate2 != null)
|
||||
throw new Exception(GlobalMessages.CitizanDupicate);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
public async Task GetExamCandidateAsync(Guid id)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue