ดิงข้อมูลหลักจาก dbกลาง

This commit is contained in:
Kittapath 2023-04-10 16:28:05 +07:00
parent 2f292d25ca
commit 4e8520eb01
44 changed files with 4642 additions and 2590 deletions

View file

@ -18,6 +18,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
#region " Fields "
private readonly ApplicationDbContext _context;
private readonly MetadataDbContext _contextMetadata;
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly MinIOService _minioService;
@ -26,10 +27,12 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
#region " Constructor and Destructor "
public PeriodExamService(ApplicationDbContext context,
MetadataDbContext contextMetadata,
IHttpContextAccessor httpContextAccessor,
MinIOService minioService)
{
_context = context;
_contextMetadata = contextMetadata;
_httpContextAccessor = httpContextAccessor;
_minioService = minioService;
}
@ -530,15 +533,33 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
if (status == "all")
{
return await _context.Candidates.AsQueryable()
var candidate = await _context.Candidates.AsQueryable()
.Include(x => x.ProfileImg)
.Where(x => x.PeriodExam == periodExam && x.Status != "register" && x.Status != "rejectRegister")
.ToListAsync();
var i = 0;
foreach (var item in candidate)
{
if (candidate[i].ProfileImg != null)
candidate[i].ProfileImg.Detail = _minioService.ImagesPath(candidate[i].ProfileImg.Id).Result;
i++;
}
return candidate;
}
else
{
return await _context.Candidates.AsQueryable()
var candidate = await _context.Candidates.AsQueryable()
.Include(x => x.ProfileImg)
.Where(x => x.PeriodExam == periodExam && x.Status == status)
.ToListAsync();
var i = 0;
foreach (var item in candidate)
{
if (candidate[i].ProfileImg != null)
candidate[i].ProfileImg.Detail = _minioService.ImagesPath(candidate[i].ProfileImg.Id).Result;
i++;
}
return candidate;
}
}
@ -548,18 +569,18 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
.Where(x => x.Id == Guid.Parse(candidateId))
.Select(x => new CandidateInformationResponseItem
{
Prefix = x.Prefix,
PrefixId = x.Prefix != null ? x.Prefix.Id.ToString() : null,
Prefix = x.PrefixName,
PrefixId = x.PrefixId != null ? x.PrefixId.ToString() : null,
FirstName = x.FirstName,
LastName = x.LastName,
Nationality = x.Nationality,
DateOfBirth = x.DateOfBirth,
Relationship = x.Relationship,
RelationshipId = x.Relationship != null ? x.Relationship.Id.ToString() : null,
CitizenProvince = x.CitizenProvince,
CitizenProvinceId = x.CitizenProvince != null ? x.CitizenProvince.Id.ToString() : null,
CitizenDistrict = x.CitizenDistrict,
CitizenDistrictId = x.CitizenDistrict != null ? x.CitizenDistrict.Id.ToString() : null,
Relationship = x.RelationshipName,
RelationshipId = x.RelationshipId != null ? x.RelationshipId.ToString() : null,
CitizenProvince = x.CitizenProvinceName,
CitizenProvinceId = x.CitizenProvinceId != null ? x.CitizenProvinceId.ToString() : null,
CitizenDistrict = x.CitizenDistrictName,
CitizenDistrictId = x.CitizenDistrictId != null ? x.CitizenDistrictId.ToString() : null,
CitizenDate = x.CitizenDate,
Email = x.Email,
CitizenId = x.CitizenId,
@ -602,21 +623,21 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
.Select(x => new CandidateAddressResponseItem
{
RegistAddress = x.RegistAddress,
RegistProvince = x.RegistProvince,
RegistProvinceId = x.RegistProvince != null ? x.RegistProvince.Id.ToString() : null,
RegistDistrict = x.RegistDistrict,
RegistDistrictId = x.RegistDistrict != null ? x.RegistDistrict.Id.ToString() : null,
RegistSubDistrict = x.RegistSubDistrict,
RegistSubDistrictId = x.RegistSubDistrict != null ? x.RegistSubDistrict.Id.ToString() : null,
RegistProvince = x.RegistProvinceName,
RegistProvinceId = x.RegistProvinceId != null ? x.RegistProvinceId.ToString() : null,
RegistDistrict = x.RegistDistrictName,
RegistDistrictId = x.RegistDistrictId != null ? x.RegistDistrictId.ToString() : null,
RegistSubDistrict = x.RegistSubDistrictName,
RegistSubDistrictId = x.RegistSubDistrictId != null ? x.RegistSubDistrictId.ToString() : null,
RegistZipCode = x.RegistZipCode,
RegistSame = x.RegistSame,
CurrentAddress = x.CurrentAddress,
CurrentProvince = x.CurrentProvince,
CurrentProvinceId = x.CurrentProvince != null ? x.CurrentProvince.Id.ToString() : null,
CurrentDistrict = x.CurrentDistrict,
CurrentDistrictId = x.CurrentDistrict != null ? x.CurrentDistrict.Id.ToString() : null,
CurrentSubDistrict = x.CurrentSubDistrict,
CurrentSubDistrictId = x.CurrentSubDistrict != null ? x.CurrentSubDistrict.Id.ToString() : null,
CurrentProvince = x.CurrentProvinceName,
CurrentProvinceId = x.CurrentProvinceId != null ? x.CurrentProvinceId.ToString() : null,
CurrentDistrict = x.CurrentDistrictName,
CurrentDistrictId = x.CurrentDistrictId != null ? x.CurrentDistrictId.ToString() : null,
CurrentSubDistrict = x.CurrentSubDistrictName,
CurrentSubDistrictId = x.CurrentSubDistrictId != null ? x.CurrentSubDistrictId.ToString() : null,
CurrentZipCode = x.CurrentZipCode,
})
.FirstOrDefaultAsync();
@ -629,20 +650,20 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
.Select(x => new CandidateFamilyResponseItem
{
Marry = x.Marry,
MarryPrefix = x.MarryPrefix,
MarryPrefixId = x.MarryPrefix != null ? x.MarryPrefix.Id.ToString() : null,
MarryPrefix = x.MarryPrefixName,
MarryPrefixId = x.MarryPrefixId != null ? x.MarryPrefixId.ToString() : null,
MarryFirstName = x.MarryFirstName,
MarryLastName = x.MarryLastName,
MarryOccupation = x.MarryOccupation,
MarryNationality = x.MarryNationality,
FatherPrefix = x.FatherPrefix,
FatherPrefixId = x.FatherPrefix != null ? x.FatherPrefix.Id.ToString() : null,
FatherPrefix = x.FatherPrefixName,
FatherPrefixId = x.FatherPrefixId != null ? x.FatherPrefixId.ToString() : null,
FatherFirstName = x.FatherFirstName,
FatherLastName = x.FatherLastName,
FatherOccupation = x.FatherOccupation,
FatherNationality = x.FatherNationality,
MotherPrefix = x.MotherPrefix,
MotherPrefixId = x.MotherPrefix != null ? x.MotherPrefix.Id.ToString() : null,
MotherPrefix = x.MotherPrefixName,
MotherPrefixId = x.MotherPrefixId != null ? x.MotherPrefixId.ToString() : null,
MotherFirstName = x.MotherFirstName,
MotherLastName = x.MotherLastName,
MotherOccupation = x.MotherOccupation,
@ -654,7 +675,6 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
public async Task<IEnumerable<Education?>> GetsAsyncEducation(string candidateId)
{
return await _context.Educations.AsQueryable()
.Include(x => x.EducationLevel)
.Where(x => x.Id == Guid.Parse(candidateId))
.OrderBy(d => d.DurationStart)
.ToListAsync();