From a2847d9d55e2e80cb4589536d750c80bdbe84366 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Sun, 8 Oct 2023 13:56:18 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88=E0=B8=A1?= =?UTF-8?q?=E0=B8=A7=E0=B8=B8=E0=B8=92=E0=B8=B4=E0=B8=81=E0=B8=B2=E0=B8=A3?= =?UTF-8?q?=E0=B8=A8=E0=B8=B4=E0=B8=81=E0=B8=A9=E0=B8=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Models/Candidate.cs | 1 + Response/CandidateEducationResponseItem.cs | 16 +- Response/CandidateResponseItem.cs | 16 +- Services/CandidateService.cs | 316 ++++++++++++++++----- 4 files changed, 256 insertions(+), 93 deletions(-) diff --git a/Models/Candidate.cs b/Models/Candidate.cs index 74f2aa2..17e420a 100644 --- a/Models/Candidate.cs +++ b/Models/Candidate.cs @@ -316,6 +316,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Models [Comment("โทรศัพท์ บุคคลที่สามารถติดต่อได้")] public string? ContactTel { get; set; } public virtual List Educations { get; set; } = new List(); + public virtual List Careers { get; set; } = new List(); } } diff --git a/Response/CandidateEducationResponseItem.cs b/Response/CandidateEducationResponseItem.cs index bb3502f..35579c4 100644 --- a/Response/CandidateEducationResponseItem.cs +++ b/Response/CandidateEducationResponseItem.cs @@ -3,13 +3,13 @@ namespace BMA.EHR.Recurit.Exam.Service.Response { public class CandidateEducationResponseItem { - public Guid EducationLevelExamId { get; set; } - public string EducationName { get; set; } = string.Empty; - public string EducationMajor { get; set; } = string.Empty; - public string EducationLocation { get; set; } = string.Empty; - public string EducationType { get; set; } = string.Empty; - public DateTime EducationEndDate { get; set; } - public string EducationScores { get; set; } = string.Empty; - public Guid EducationLevelHighId { get; set; } + public Guid? EducationLevelExamId { get; set; } + public string? EducationName { get; set; } = string.Empty; + public string? EducationMajor { get; set; } = string.Empty; + public string? EducationLocation { get; set; } = string.Empty; + public string? EducationType { get; set; } = string.Empty; + public DateTime? EducationEndDate { get; set; } + public string? EducationScores { get; set; } = string.Empty; + public Guid? EducationLevelHighId { get; set; } } } diff --git a/Response/CandidateResponseItem.cs b/Response/CandidateResponseItem.cs index ebed8c2..e5a8ded 100644 --- a/Response/CandidateResponseItem.cs +++ b/Response/CandidateResponseItem.cs @@ -78,14 +78,14 @@ namespace BMA.EHR.Recurit.Exam.Service.Response public string? OccupationPositionType { get; set; } public string? OccupationTelephone { get; set; } - public Guid EducationLevelExamId { get; set; } - public string EducationName { get; set; } = string.Empty; - public string EducationMajor { get; set; } = string.Empty; - public string EducationLocation { get; set; } = string.Empty; - public string EducationType { get; set; } = string.Empty; - public DateTime EducationEndDate { get; set; } - public string EducationScores { get; set; } = string.Empty; - public Guid EducationLevelHighId { get; set; } + public Guid? EducationLevelExamId { get; set; } + public string? EducationName { get; set; } = string.Empty; + public string? EducationMajor { get; set; } = string.Empty; + public string? EducationLocation { get; set; } = string.Empty; + public string? EducationType { get; set; } = string.Empty; + public DateTime? EducationEndDate { get; set; } + public string? EducationScores { get; set; } = string.Empty; + public Guid? EducationLevelHighId { get; set; } public Guid? ContactPrefixId { get; set; } public string? ContactFirstname { get; set; } diff --git a/Services/CandidateService.cs b/Services/CandidateService.cs index 137bb96..7db67d7 100644 --- a/Services/CandidateService.cs +++ b/Services/CandidateService.cs @@ -1,5 +1,6 @@ using System.Security.Claims; using BMA.EHR.Domain.Models.Placement; +using BMA.EHR.Extensions; using BMA.EHR.Recurit.Exam.Service.Core; using BMA.EHR.Recurit.Exam.Service.Data; using BMA.EHR.Recurit.Exam.Service.Models; @@ -875,33 +876,17 @@ namespace BMA.EHR.Recurit.Exam.Service.Services candidate.ContactLastname = updated.ContactLastname; candidate.ContactRelations = updated.ContactRelations; candidate.ContactTel = updated.ContactTel; - - var educationLevelExam = await _contextMetadata.EducationLevels.AsQueryable() - .FirstOrDefaultAsync(x => x.Id == updated.EducationLevelExamId); - - if (educationLevelExam == null) - throw new Exception(GlobalMessages.EducationLevelNotFound); - - var educationLevelHigh = await _contextMetadata.EducationLevels.AsQueryable() - .FirstOrDefaultAsync(x => x.Id == updated.EducationLevelHighId); - - if (educationLevelHigh == null) - throw new Exception(GlobalMessages.EducationLevelNotFound); if (candidate.Educations.FirstOrDefault() == null) { var education = new Education { Candidate = candidate, - EducationLevelExamId = educationLevelExam.Id, - EducationLevelExamName = educationLevelExam.Name, EducationName = updated.EducationName, EducationMajor = updated.EducationMajor, EducationLocation = updated.EducationLocation, EducationType = updated.EducationType, EducationEndDate = updated.EducationEndDate, EducationScores = updated.EducationScores, - EducationLevelHighId = educationLevelHigh.Id, - EducationLevelHighName = educationLevelHigh.Name, CreatedAt = DateTime.Now, CreatedUserId = UserId ?? "", CreatedFullName = FullName ?? "", @@ -909,23 +894,61 @@ namespace BMA.EHR.Recurit.Exam.Service.Services LastUpdateUserId = UserId ?? "", LastUpdateFullName = FullName ?? "", }; + if (updated.EducationLevelExamId != null) + { + var educationLevelExam = await _contextMetadata.EducationLevels.AsQueryable() + .FirstOrDefaultAsync(x => x.Id == updated.EducationLevelExamId); + + if (educationLevelExam == null) + throw new Exception(GlobalMessages.EducationLevelNotFound); + education.EducationLevelExamId = educationLevelExam.Id; + education.EducationLevelExamName = educationLevelExam.Name; + } + + if (updated.EducationLevelHighId != null) + { + var educationLevelHigh = await _contextMetadata.EducationLevels.AsQueryable() + .FirstOrDefaultAsync(x => x.Id == updated.EducationLevelHighId); + + if (educationLevelHigh == null) + throw new Exception(GlobalMessages.EducationLevelNotFound); + education.EducationLevelHighId = educationLevelHigh.Id; + education.EducationLevelHighName = educationLevelHigh.Name; + } await _context.Educations.AddAsync(education); } else { - candidate.Educations.FirstOrDefault().EducationLevelExamId = educationLevelExam.Id; - candidate.Educations.FirstOrDefault().EducationLevelExamName = educationLevelExam.Name; candidate.Educations.FirstOrDefault().EducationName = updated.EducationName; candidate.Educations.FirstOrDefault().EducationMajor = updated.EducationMajor; candidate.Educations.FirstOrDefault().EducationLocation = updated.EducationLocation; candidate.Educations.FirstOrDefault().EducationType = updated.EducationType; candidate.Educations.FirstOrDefault().EducationEndDate = updated.EducationEndDate; candidate.Educations.FirstOrDefault().EducationScores = updated.EducationScores; - candidate.Educations.FirstOrDefault().EducationLevelHighId = educationLevelHigh.Id; - candidate.Educations.FirstOrDefault().EducationLevelHighName = educationLevelHigh.Name; candidate.Educations.FirstOrDefault().LastUpdatedAt = DateTime.Now; candidate.Educations.FirstOrDefault().LastUpdateUserId = UserId ?? ""; candidate.Educations.FirstOrDefault().LastUpdateFullName = FullName ?? ""; + if (updated.EducationLevelExamId != null) + { + var educationLevelExam = await _contextMetadata.EducationLevels.AsQueryable() + .FirstOrDefaultAsync(x => x.Id == updated.EducationLevelExamId); + + if (educationLevelExam == null) + throw new Exception(GlobalMessages.EducationLevelNotFound); + candidate.Educations.FirstOrDefault().EducationLevelExamId = educationLevelExam.Id; + candidate.Educations.FirstOrDefault().EducationLevelExamName = educationLevelExam.Name; + } + + if (updated.EducationLevelHighId != null) + { + var educationLevelHigh = await _contextMetadata.EducationLevels.AsQueryable() + .FirstOrDefaultAsync(x => x.Id == updated.EducationLevelHighId); + + if (educationLevelHigh == null) + throw new Exception(GlobalMessages.EducationLevelNotFound); + candidate.Educations.FirstOrDefault().EducationLevelHighId = educationLevelHigh.Id; + candidate.Educations.FirstOrDefault().EducationLevelHighName = educationLevelHigh.Name; + } } await _context.SaveChangesAsync(); @@ -1078,32 +1101,17 @@ namespace BMA.EHR.Recurit.Exam.Service.Services candidate.ContactRelations = updated.ContactRelations; candidate.ContactTel = updated.ContactTel; - var educationLevelExam = await _contextMetadata.EducationLevels.AsQueryable() - .FirstOrDefaultAsync(x => x.Id == updated.EducationLevelExamId); - - if (educationLevelExam == null) - throw new Exception(GlobalMessages.EducationLevelNotFound); - - var educationLevelHigh = await _contextMetadata.EducationLevels.AsQueryable() - .FirstOrDefaultAsync(x => x.Id == updated.EducationLevelHighId); - - if (educationLevelHigh == null) - throw new Exception(GlobalMessages.EducationLevelNotFound); if (candidate.Educations.FirstOrDefault() == null) { var education = new Education { Candidate = candidate, - EducationLevelExamId = educationLevelExam.Id, - EducationLevelExamName = educationLevelExam.Name, EducationName = updated.EducationName, EducationMajor = updated.EducationMajor, EducationLocation = updated.EducationLocation, EducationType = updated.EducationType, EducationEndDate = updated.EducationEndDate, EducationScores = updated.EducationScores, - EducationLevelHighId = educationLevelHigh.Id, - EducationLevelHighName = educationLevelHigh.Name, CreatedAt = DateTime.Now, CreatedUserId = UserId ?? "", CreatedFullName = FullName ?? "", @@ -1111,23 +1119,61 @@ namespace BMA.EHR.Recurit.Exam.Service.Services LastUpdateUserId = UserId ?? "", LastUpdateFullName = FullName ?? "", }; + if (updated.EducationLevelExamId != null) + { + var educationLevelExam = await _contextMetadata.EducationLevels.AsQueryable() + .FirstOrDefaultAsync(x => x.Id == updated.EducationLevelExamId); + + if (educationLevelExam == null) + throw new Exception(GlobalMessages.EducationLevelNotFound); + education.EducationLevelExamId = educationLevelExam.Id; + education.EducationLevelExamName = educationLevelExam.Name; + } + + if (updated.EducationLevelHighId != null) + { + var educationLevelHigh = await _contextMetadata.EducationLevels.AsQueryable() + .FirstOrDefaultAsync(x => x.Id == updated.EducationLevelHighId); + + if (educationLevelHigh == null) + throw new Exception(GlobalMessages.EducationLevelNotFound); + education.EducationLevelHighId = educationLevelHigh.Id; + education.EducationLevelHighName = educationLevelHigh.Name; + } await _context.Educations.AddAsync(education); } else { - candidate.Educations.FirstOrDefault().EducationLevelExamId = educationLevelExam.Id; - candidate.Educations.FirstOrDefault().EducationLevelExamName = educationLevelExam.Name; candidate.Educations.FirstOrDefault().EducationName = updated.EducationName; candidate.Educations.FirstOrDefault().EducationMajor = updated.EducationMajor; candidate.Educations.FirstOrDefault().EducationLocation = updated.EducationLocation; candidate.Educations.FirstOrDefault().EducationType = updated.EducationType; candidate.Educations.FirstOrDefault().EducationEndDate = updated.EducationEndDate; candidate.Educations.FirstOrDefault().EducationScores = updated.EducationScores; - candidate.Educations.FirstOrDefault().EducationLevelHighId = educationLevelHigh.Id; - candidate.Educations.FirstOrDefault().EducationLevelHighName = educationLevelHigh.Name; candidate.Educations.FirstOrDefault().LastUpdatedAt = DateTime.Now; candidate.Educations.FirstOrDefault().LastUpdateUserId = UserId ?? ""; candidate.Educations.FirstOrDefault().LastUpdateFullName = FullName ?? ""; + if (updated.EducationLevelExamId != null) + { + var educationLevelExam = await _contextMetadata.EducationLevels.AsQueryable() + .FirstOrDefaultAsync(x => x.Id == updated.EducationLevelExamId); + + if (educationLevelExam == null) + throw new Exception(GlobalMessages.EducationLevelNotFound); + candidate.Educations.FirstOrDefault().EducationLevelExamId = educationLevelExam.Id; + candidate.Educations.FirstOrDefault().EducationLevelExamName = educationLevelExam.Name; + } + + if (updated.EducationLevelHighId != null) + { + var educationLevelHigh = await _contextMetadata.EducationLevels.AsQueryable() + .FirstOrDefaultAsync(x => x.Id == updated.EducationLevelHighId); + + if (educationLevelHigh == null) + throw new Exception(GlobalMessages.EducationLevelNotFound); + candidate.Educations.FirstOrDefault().EducationLevelHighId = educationLevelHigh.Id; + candidate.Educations.FirstOrDefault().EducationLevelHighName = educationLevelHigh.Name; + } } await _context.SaveChangesAsync(); } @@ -1615,32 +1661,17 @@ namespace BMA.EHR.Recurit.Exam.Service.Services if (candidate == null) throw new Exception(GlobalMessages.CandidateNotFound); - var educationLevelExam = await _contextMetadata.EducationLevels.AsQueryable() - .FirstOrDefaultAsync(x => x.Id == updated.EducationLevelExamId); - - if (educationLevelExam == null) - throw new Exception(GlobalMessages.EducationLevelNotFound); - - var educationLevelHigh = await _contextMetadata.EducationLevels.AsQueryable() - .FirstOrDefaultAsync(x => x.Id == updated.EducationLevelHighId); - - if (educationLevelHigh == null) - throw new Exception(GlobalMessages.EducationLevelNotFound); if (candidate.Educations.FirstOrDefault() == null) { var education = new Education { Candidate = candidate, - EducationLevelExamId = educationLevelExam.Id, - EducationLevelExamName = educationLevelExam.Name, EducationName = updated.EducationName, EducationMajor = updated.EducationMajor, EducationLocation = updated.EducationLocation, EducationType = updated.EducationType, EducationEndDate = updated.EducationEndDate, EducationScores = updated.EducationScores, - EducationLevelHighId = educationLevelHigh.Id, - EducationLevelHighName = educationLevelHigh.Name, CreatedAt = DateTime.Now, CreatedUserId = UserId ?? "", CreatedFullName = FullName ?? "", @@ -1648,23 +1679,61 @@ namespace BMA.EHR.Recurit.Exam.Service.Services LastUpdateUserId = UserId ?? "", LastUpdateFullName = FullName ?? "", }; + if (updated.EducationLevelExamId != null) + { + var educationLevelExam = await _contextMetadata.EducationLevels.AsQueryable() + .FirstOrDefaultAsync(x => x.Id == updated.EducationLevelExamId); + + if (educationLevelExam == null) + throw new Exception(GlobalMessages.EducationLevelNotFound); + education.EducationLevelExamId = educationLevelExam.Id; + education.EducationLevelExamName = educationLevelExam.Name; + } + + if (updated.EducationLevelHighId != null) + { + var educationLevelHigh = await _contextMetadata.EducationLevels.AsQueryable() + .FirstOrDefaultAsync(x => x.Id == updated.EducationLevelHighId); + + if (educationLevelHigh == null) + throw new Exception(GlobalMessages.EducationLevelNotFound); + education.EducationLevelHighId = educationLevelHigh.Id; + education.EducationLevelHighName = educationLevelHigh.Name; + } await _context.Educations.AddAsync(education); } else { - candidate.Educations.FirstOrDefault().EducationLevelExamId = educationLevelExam.Id; - candidate.Educations.FirstOrDefault().EducationLevelExamName = educationLevelExam.Name; candidate.Educations.FirstOrDefault().EducationName = updated.EducationName; candidate.Educations.FirstOrDefault().EducationMajor = updated.EducationMajor; candidate.Educations.FirstOrDefault().EducationLocation = updated.EducationLocation; candidate.Educations.FirstOrDefault().EducationType = updated.EducationType; candidate.Educations.FirstOrDefault().EducationEndDate = updated.EducationEndDate; candidate.Educations.FirstOrDefault().EducationScores = updated.EducationScores; - candidate.Educations.FirstOrDefault().EducationLevelHighId = educationLevelHigh.Id; - candidate.Educations.FirstOrDefault().EducationLevelHighName = educationLevelHigh.Name; candidate.Educations.FirstOrDefault().LastUpdatedAt = DateTime.Now; candidate.Educations.FirstOrDefault().LastUpdateUserId = UserId ?? ""; candidate.Educations.FirstOrDefault().LastUpdateFullName = FullName ?? ""; + if (updated.EducationLevelExamId != null) + { + var educationLevelExam = await _contextMetadata.EducationLevels.AsQueryable() + .FirstOrDefaultAsync(x => x.Id == updated.EducationLevelExamId); + + if (educationLevelExam == null) + throw new Exception(GlobalMessages.EducationLevelNotFound); + candidate.Educations.FirstOrDefault().EducationLevelExamId = educationLevelExam.Id; + candidate.Educations.FirstOrDefault().EducationLevelExamName = educationLevelExam.Name; + } + + if (updated.EducationLevelHighId != null) + { + var educationLevelHigh = await _contextMetadata.EducationLevels.AsQueryable() + .FirstOrDefaultAsync(x => x.Id == updated.EducationLevelHighId); + + if (educationLevelHigh == null) + throw new Exception(GlobalMessages.EducationLevelNotFound); + candidate.Educations.FirstOrDefault().EducationLevelHighId = educationLevelHigh.Id; + candidate.Educations.FirstOrDefault().EducationLevelHighName = educationLevelHigh.Name; + } } await _context.SaveChangesAsync(); @@ -1678,32 +1747,17 @@ namespace BMA.EHR.Recurit.Exam.Service.Services if (candidate == null) throw new Exception(GlobalMessages.CandidateNotFound); - var educationLevelExam = await _contextMetadata.EducationLevels.AsQueryable() - .FirstOrDefaultAsync(x => x.Id == updated.EducationLevelExamId); - - if (educationLevelExam == null) - throw new Exception(GlobalMessages.EducationLevelNotFound); - - var educationLevelHigh = await _contextMetadata.EducationLevels.AsQueryable() - .FirstOrDefaultAsync(x => x.Id == updated.EducationLevelHighId); - - if (educationLevelHigh == null) - throw new Exception(GlobalMessages.EducationLevelNotFound); if (candidate.Educations.FirstOrDefault() == null) { var education = new Education { Candidate = candidate, - EducationLevelExamId = educationLevelExam.Id, - EducationLevelExamName = educationLevelExam.Name, EducationName = updated.EducationName, EducationMajor = updated.EducationMajor, EducationLocation = updated.EducationLocation, EducationType = updated.EducationType, EducationEndDate = updated.EducationEndDate, EducationScores = updated.EducationScores, - EducationLevelHighId = educationLevelHigh.Id, - EducationLevelHighName = educationLevelHigh.Name, CreatedAt = DateTime.Now, CreatedUserId = UserId ?? "", CreatedFullName = FullName ?? "", @@ -1711,23 +1765,61 @@ namespace BMA.EHR.Recurit.Exam.Service.Services LastUpdateUserId = UserId ?? "", LastUpdateFullName = FullName ?? "", }; + if (updated.EducationLevelExamId != null) + { + var educationLevelExam = await _contextMetadata.EducationLevels.AsQueryable() + .FirstOrDefaultAsync(x => x.Id == updated.EducationLevelExamId); + + if (educationLevelExam == null) + throw new Exception(GlobalMessages.EducationLevelNotFound); + education.EducationLevelExamId = educationLevelExam.Id; + education.EducationLevelExamName = educationLevelExam.Name; + } + + if (updated.EducationLevelHighId != null) + { + var educationLevelHigh = await _contextMetadata.EducationLevels.AsQueryable() + .FirstOrDefaultAsync(x => x.Id == updated.EducationLevelHighId); + + if (educationLevelHigh == null) + throw new Exception(GlobalMessages.EducationLevelNotFound); + education.EducationLevelHighId = educationLevelHigh.Id; + education.EducationLevelHighName = educationLevelHigh.Name; + } await _context.Educations.AddAsync(education); } else { - candidate.Educations.FirstOrDefault().EducationLevelExamId = educationLevelExam.Id; - candidate.Educations.FirstOrDefault().EducationLevelExamName = educationLevelExam.Name; candidate.Educations.FirstOrDefault().EducationName = updated.EducationName; candidate.Educations.FirstOrDefault().EducationMajor = updated.EducationMajor; candidate.Educations.FirstOrDefault().EducationLocation = updated.EducationLocation; candidate.Educations.FirstOrDefault().EducationType = updated.EducationType; candidate.Educations.FirstOrDefault().EducationEndDate = updated.EducationEndDate; candidate.Educations.FirstOrDefault().EducationScores = updated.EducationScores; - candidate.Educations.FirstOrDefault().EducationLevelHighId = educationLevelHigh.Id; - candidate.Educations.FirstOrDefault().EducationLevelHighName = educationLevelHigh.Name; candidate.Educations.FirstOrDefault().LastUpdatedAt = DateTime.Now; candidate.Educations.FirstOrDefault().LastUpdateUserId = UserId ?? ""; candidate.Educations.FirstOrDefault().LastUpdateFullName = FullName ?? ""; + if (updated.EducationLevelExamId != null) + { + var educationLevelExam = await _contextMetadata.EducationLevels.AsQueryable() + .FirstOrDefaultAsync(x => x.Id == updated.EducationLevelExamId); + + if (educationLevelExam == null) + throw new Exception(GlobalMessages.EducationLevelNotFound); + candidate.Educations.FirstOrDefault().EducationLevelExamId = educationLevelExam.Id; + candidate.Educations.FirstOrDefault().EducationLevelExamName = educationLevelExam.Name; + } + + if (updated.EducationLevelHighId != null) + { + var educationLevelHigh = await _contextMetadata.EducationLevels.AsQueryable() + .FirstOrDefaultAsync(x => x.Id == updated.EducationLevelHighId); + + if (educationLevelHigh == null) + throw new Exception(GlobalMessages.EducationLevelNotFound); + candidate.Educations.FirstOrDefault().EducationLevelHighId = educationLevelHigh.Id; + candidate.Educations.FirstOrDefault().EducationLevelHighName = educationLevelHigh.Name; + } } await _context.SaveChangesAsync(); } @@ -2332,6 +2424,76 @@ namespace BMA.EHR.Recurit.Exam.Service.Services throw new Exception(GlobalMessages.CitizanDupicate); } + public async Task GetExamCandidateAsync(Guid id) + { + var exam = await _context.Candidates.AsQueryable() + .Where(x => x.Id == id) + .Select(p => new + { + p.Id, + ExamIdenNumber = p.ExamIdenNumber, + PositionName = p.PositionExam == null ? "" : p.PositionExam.PositionName, + PeriodExamName = p.PeriodExam == null ? "" : p.PeriodExam.Name, + + FullName = $"{p.PrefixName}{p.FirstName} {p.LastName}", + Religion = p.ReligionName, + Nationality = p.Nationality, + DateOfBirth = p.DateOfBirth == null ? "" : p.DateOfBirth.Value.ToThaiFullDate(), + Age = p.DateOfBirth == null ? "" : p.DateOfBirth.Value.CalculateAgeStrV2(0, 0), + CitizenId = p.CitizenId, + + EducationLevelExamName = p.Educations.FirstOrDefault() == null ? "" : p.Educations.FirstOrDefault().EducationLevelExamName, + EducationName = p.Educations.FirstOrDefault() == null ? "" : p.Educations.FirstOrDefault().EducationName, + EducationMajor = p.Educations.FirstOrDefault() == null ? "" : p.Educations.FirstOrDefault().EducationMajor, + EducationLocation = p.Educations.FirstOrDefault() == null ? "" : p.Educations.FirstOrDefault().EducationLocation, + EducationEndDate = p.Educations.FirstOrDefault() == null || p.Educations.FirstOrDefault().EducationEndDate == null ? "" : p.Educations.FirstOrDefault().EducationEndDate.Value.ToThaiFullDate(), + EducationScores = p.Educations.FirstOrDefault() == null ? "" : p.Educations.FirstOrDefault().EducationScores, + EducationType = p.Educations.FirstOrDefault() == null ? "" : p.Educations.FirstOrDefault().EducationType, + EducationLevelHighName = p.Educations.FirstOrDefault() == null ? "" : p.Educations.FirstOrDefault().EducationLevelHighName, + + OccupationPositionType = p.OccupationPositionType, + OccupationPosition = p.OccupationPosition, + OccupationSalary = p.OccupationSalary, + OccupationGroup = p.OccupationGroup, + OccupationPile = p.OccupationPile, + OccupationOrg = p.OccupationOrg, + OccupationTelephone = p.OccupationTelephone, + + Careers = p.Careers.Select(y => new + { + Position = y.Position, + Type = y.Type, + DurationStart = y.DurationStart.ToThaiFullDate(), + DurationEnd = y.DurationEnd.ToThaiFullDate(), + RangeDate = y.RangeDate, + }), + + RegistAddress = p.RegistAddress, + RegistProvinceName = p.RegistProvinceName, + RegistDistrictName = p.RegistDistrictName, + RegistSubDistrictName = p.RegistSubDistrictName, + RegistZipCode = p.RegistZipCode, + CurrentAddress = p.CurrentAddress, + CurrentProvinceName = p.CurrentProvinceName, + CurrentSubDistrictName = p.CurrentSubDistrictName, + CurrentDistrictName = p.CurrentDistrictName, + CurrentZipCode = p.CurrentZipCode, + Telephone = p.Telephone, + Email = p.Email, + + ContactFullName = $"{p.ContactPrefixName}{p.ContactFirstname} {p.ContactLastname}", + ContactRelations = p.ContactRelations, + ContactTel = p.ContactTel, + + RegisterDate = p.RegisterDate == null ? "" : p.RegisterDate.Value.ToThaiFullDate(), + }) + .FirstOrDefaultAsync(); + + if (exam == null) + throw new Exception(GlobalMessages.CandidateNotFound); + + } + #endregion } }