เพิ่มวัหมดอายุเลขบัตร

This commit is contained in:
Kittapath 2023-03-24 11:50:46 +07:00
parent a781c375d7
commit 7018791857
9 changed files with 638 additions and 285 deletions

View file

@ -50,11 +50,18 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
.Select(x => new CandidateInformationResponseItem
{
Prefix = x.Prefix,
PrefixId = x.Prefix != null ? x.Prefix.Id.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,
CitizenDate = x.CitizenDate,
Email = x.Email,
CitizenId = x.CitizenId,
})
@ -75,14 +82,20 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
{
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,
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,
CurrentZipCode = x.CurrentZipCode,
})
.FirstOrDefaultAsync();
@ -102,12 +115,15 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
{
Marry = x.Marry,
MarryPrefix = x.MarryPrefix,
MarryPrefixId = x.MarryPrefix != null ? x.MarryPrefix.Id.ToString() : null,
MarryFirstName = x.MarryFirstName,
MarryLastName = x.MarryLastName,
FatherPrefix = x.FatherPrefix,
FatherPrefixId = x.FatherPrefix != null ? x.FatherPrefix.Id.ToString() : null,
FatherFirstName = x.FatherFirstName,
FatherLastName = x.FatherLastName,
MotherPrefix = x.MotherPrefix,
MotherPrefixId = x.MotherPrefix != null ? x.MotherPrefix.Id.ToString() : null,
MotherFirstName = x.MotherFirstName,
MotherLastName = x.MotherLastName,
})
@ -252,12 +268,33 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
candidate.Relationship = relationship;
}
if (updated.CitizenProvinceId != null)
{
var citizenProvince = await _context.Provinces.AsQueryable()
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(updated.CitizenProvinceId));
if (citizenProvince == null)
throw new Exception(GlobalMessages.ProvinceNotFound);
candidate.CitizenProvince = citizenProvince;
}
if (updated.CitizenDistrictId != null)
{
var citizenDistrict = await _context.Districts.AsQueryable()
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(updated.CitizenDistrictId));
if (citizenDistrict == null)
throw new Exception(GlobalMessages.DistrictNotFound);
candidate.CitizenDistrict = citizenDistrict;
}
candidate.FirstName = updated.FirstName;
candidate.LastName = updated.LastName;
candidate.Nationality = updated.Nationality;
candidate.DateOfBirth = updated.DateOfBirth;
candidate.Email = updated.Email;
candidate.CitizenId = updated.CitizenId;
candidate.CitizenDate = updated.CitizenDate;
await _context.SaveChangesAsync();
}
@ -282,16 +319,6 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
candidate.RegistProvince = registProvince;
}
if (updated.RegistProvinceId != null)
{
var registProvince = await _context.Provinces.AsQueryable()
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(updated.RegistProvinceId));
if (registProvince == null)
throw new Exception(GlobalMessages.ProvinceNotFound);
candidate.RegistProvince = registProvince;
}
if (updated.RegistDistrictId != null)
{
var registDistrict = await _context.Districts.AsQueryable()
@ -323,16 +350,6 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
candidate.CurrentProvince = currentProvince;
}
if (updated.CurrentProvinceId != null)
{
var currentProvince = await _context.Provinces.AsQueryable()
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(updated.CurrentProvinceId));
if (currentProvince == null)
throw new Exception(GlobalMessages.ProvinceNotFound);
candidate.CurrentProvince = currentProvince;
}
if (updated.CurrentDistrictId != null)
{
var currentDistrict = await _context.Districts.AsQueryable()
@ -543,7 +560,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
await _context.SaveChangesAsync();
}
public async Task RegisterCandidateService(string examId)
public async Task<string> GetStatusCandidateService(string examId)
{
var exam = await _context.PeriodExams.AsQueryable()
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(examId));
@ -557,7 +574,37 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
if (candidate == null)
throw new Exception(GlobalMessages.CandidateNotFound);
candidate.status = "registered";
return candidate.status;
}
public async Task UserCheckCandidateService(string examId, string status)
{
var exam = await _context.PeriodExams.AsQueryable()
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(examId));
if (exam == null)
throw new Exception(GlobalMessages.ExamNotFound);
var candidate = await _context.Candidates.AsQueryable()
.FirstOrDefaultAsync(x => x.PeriodExam == exam && x.UserId == UserId);
if (candidate == null)
throw new Exception(GlobalMessages.CandidateNotFound);
candidate.status = status;
await _context.SaveChangesAsync();
}
public async Task AdminCheckCandidateService(string candidateId, string status)
{
var candidate = await _context.Candidates.AsQueryable()
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(candidateId));
if (candidate == null)
throw new Exception(GlobalMessages.CandidateNotFound);
candidate.status = status;
await _context.SaveChangesAsync();
}