เพิ่มวุฒิการศิกษา
This commit is contained in:
parent
77d397a8d8
commit
a2847d9d55
4 changed files with 256 additions and 93 deletions
|
|
@ -316,6 +316,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Models
|
||||||
[Comment("โทรศัพท์ บุคคลที่สามารถติดต่อได้")]
|
[Comment("โทรศัพท์ บุคคลที่สามารถติดต่อได้")]
|
||||||
public string? ContactTel { get; set; }
|
public string? ContactTel { get; set; }
|
||||||
public virtual List<Education> Educations { get; set; } = new List<Education>();
|
public virtual List<Education> Educations { get; set; } = new List<Education>();
|
||||||
|
public virtual List<Career> Careers { get; set; } = new List<Career>();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,13 @@ namespace BMA.EHR.Recurit.Exam.Service.Response
|
||||||
{
|
{
|
||||||
public class CandidateEducationResponseItem
|
public class CandidateEducationResponseItem
|
||||||
{
|
{
|
||||||
public Guid EducationLevelExamId { get; set; }
|
public Guid? EducationLevelExamId { get; set; }
|
||||||
public string EducationName { get; set; } = string.Empty;
|
public string? EducationName { get; set; } = string.Empty;
|
||||||
public string EducationMajor { get; set; } = string.Empty;
|
public string? EducationMajor { get; set; } = string.Empty;
|
||||||
public string EducationLocation { get; set; } = string.Empty;
|
public string? EducationLocation { get; set; } = string.Empty;
|
||||||
public string EducationType { get; set; } = string.Empty;
|
public string? EducationType { get; set; } = string.Empty;
|
||||||
public DateTime EducationEndDate { get; set; }
|
public DateTime? EducationEndDate { get; set; }
|
||||||
public string EducationScores { get; set; } = string.Empty;
|
public string? EducationScores { get; set; } = string.Empty;
|
||||||
public Guid EducationLevelHighId { get; set; }
|
public Guid? EducationLevelHighId { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -78,14 +78,14 @@ namespace BMA.EHR.Recurit.Exam.Service.Response
|
||||||
public string? OccupationPositionType { get; set; }
|
public string? OccupationPositionType { get; set; }
|
||||||
public string? OccupationTelephone { get; set; }
|
public string? OccupationTelephone { get; set; }
|
||||||
|
|
||||||
public Guid EducationLevelExamId { get; set; }
|
public Guid? EducationLevelExamId { get; set; }
|
||||||
public string EducationName { get; set; } = string.Empty;
|
public string? EducationName { get; set; } = string.Empty;
|
||||||
public string EducationMajor { get; set; } = string.Empty;
|
public string? EducationMajor { get; set; } = string.Empty;
|
||||||
public string EducationLocation { get; set; } = string.Empty;
|
public string? EducationLocation { get; set; } = string.Empty;
|
||||||
public string EducationType { get; set; } = string.Empty;
|
public string? EducationType { get; set; } = string.Empty;
|
||||||
public DateTime EducationEndDate { get; set; }
|
public DateTime? EducationEndDate { get; set; }
|
||||||
public string EducationScores { get; set; } = string.Empty;
|
public string? EducationScores { get; set; } = string.Empty;
|
||||||
public Guid EducationLevelHighId { get; set; }
|
public Guid? EducationLevelHighId { get; set; }
|
||||||
|
|
||||||
public Guid? ContactPrefixId { get; set; }
|
public Guid? ContactPrefixId { get; set; }
|
||||||
public string? ContactFirstname { get; set; }
|
public string? ContactFirstname { get; set; }
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
using BMA.EHR.Domain.Models.Placement;
|
using BMA.EHR.Domain.Models.Placement;
|
||||||
|
using BMA.EHR.Extensions;
|
||||||
using BMA.EHR.Recurit.Exam.Service.Core;
|
using BMA.EHR.Recurit.Exam.Service.Core;
|
||||||
using BMA.EHR.Recurit.Exam.Service.Data;
|
using BMA.EHR.Recurit.Exam.Service.Data;
|
||||||
using BMA.EHR.Recurit.Exam.Service.Models;
|
using BMA.EHR.Recurit.Exam.Service.Models;
|
||||||
|
|
@ -875,33 +876,17 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
||||||
candidate.ContactLastname = updated.ContactLastname;
|
candidate.ContactLastname = updated.ContactLastname;
|
||||||
candidate.ContactRelations = updated.ContactRelations;
|
candidate.ContactRelations = updated.ContactRelations;
|
||||||
candidate.ContactTel = updated.ContactTel;
|
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)
|
if (candidate.Educations.FirstOrDefault() == null)
|
||||||
{
|
{
|
||||||
var education = new Education
|
var education = new Education
|
||||||
{
|
{
|
||||||
Candidate = candidate,
|
Candidate = candidate,
|
||||||
EducationLevelExamId = educationLevelExam.Id,
|
|
||||||
EducationLevelExamName = educationLevelExam.Name,
|
|
||||||
EducationName = updated.EducationName,
|
EducationName = updated.EducationName,
|
||||||
EducationMajor = updated.EducationMajor,
|
EducationMajor = updated.EducationMajor,
|
||||||
EducationLocation = updated.EducationLocation,
|
EducationLocation = updated.EducationLocation,
|
||||||
EducationType = updated.EducationType,
|
EducationType = updated.EducationType,
|
||||||
EducationEndDate = updated.EducationEndDate,
|
EducationEndDate = updated.EducationEndDate,
|
||||||
EducationScores = updated.EducationScores,
|
EducationScores = updated.EducationScores,
|
||||||
EducationLevelHighId = educationLevelHigh.Id,
|
|
||||||
EducationLevelHighName = educationLevelHigh.Name,
|
|
||||||
CreatedAt = DateTime.Now,
|
CreatedAt = DateTime.Now,
|
||||||
CreatedUserId = UserId ?? "",
|
CreatedUserId = UserId ?? "",
|
||||||
CreatedFullName = FullName ?? "",
|
CreatedFullName = FullName ?? "",
|
||||||
|
|
@ -909,23 +894,61 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
||||||
LastUpdateUserId = UserId ?? "",
|
LastUpdateUserId = UserId ?? "",
|
||||||
LastUpdateFullName = FullName ?? "",
|
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);
|
await _context.Educations.AddAsync(education);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
candidate.Educations.FirstOrDefault().EducationLevelExamId = educationLevelExam.Id;
|
|
||||||
candidate.Educations.FirstOrDefault().EducationLevelExamName = educationLevelExam.Name;
|
|
||||||
candidate.Educations.FirstOrDefault().EducationName = updated.EducationName;
|
candidate.Educations.FirstOrDefault().EducationName = updated.EducationName;
|
||||||
candidate.Educations.FirstOrDefault().EducationMajor = updated.EducationMajor;
|
candidate.Educations.FirstOrDefault().EducationMajor = updated.EducationMajor;
|
||||||
candidate.Educations.FirstOrDefault().EducationLocation = updated.EducationLocation;
|
candidate.Educations.FirstOrDefault().EducationLocation = updated.EducationLocation;
|
||||||
candidate.Educations.FirstOrDefault().EducationType = updated.EducationType;
|
candidate.Educations.FirstOrDefault().EducationType = updated.EducationType;
|
||||||
candidate.Educations.FirstOrDefault().EducationEndDate = updated.EducationEndDate;
|
candidate.Educations.FirstOrDefault().EducationEndDate = updated.EducationEndDate;
|
||||||
candidate.Educations.FirstOrDefault().EducationScores = updated.EducationScores;
|
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().LastUpdatedAt = DateTime.Now;
|
||||||
candidate.Educations.FirstOrDefault().LastUpdateUserId = UserId ?? "";
|
candidate.Educations.FirstOrDefault().LastUpdateUserId = UserId ?? "";
|
||||||
candidate.Educations.FirstOrDefault().LastUpdateFullName = FullName ?? "";
|
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();
|
await _context.SaveChangesAsync();
|
||||||
|
|
@ -1078,32 +1101,17 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
||||||
candidate.ContactRelations = updated.ContactRelations;
|
candidate.ContactRelations = updated.ContactRelations;
|
||||||
candidate.ContactTel = updated.ContactTel;
|
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)
|
if (candidate.Educations.FirstOrDefault() == null)
|
||||||
{
|
{
|
||||||
var education = new Education
|
var education = new Education
|
||||||
{
|
{
|
||||||
Candidate = candidate,
|
Candidate = candidate,
|
||||||
EducationLevelExamId = educationLevelExam.Id,
|
|
||||||
EducationLevelExamName = educationLevelExam.Name,
|
|
||||||
EducationName = updated.EducationName,
|
EducationName = updated.EducationName,
|
||||||
EducationMajor = updated.EducationMajor,
|
EducationMajor = updated.EducationMajor,
|
||||||
EducationLocation = updated.EducationLocation,
|
EducationLocation = updated.EducationLocation,
|
||||||
EducationType = updated.EducationType,
|
EducationType = updated.EducationType,
|
||||||
EducationEndDate = updated.EducationEndDate,
|
EducationEndDate = updated.EducationEndDate,
|
||||||
EducationScores = updated.EducationScores,
|
EducationScores = updated.EducationScores,
|
||||||
EducationLevelHighId = educationLevelHigh.Id,
|
|
||||||
EducationLevelHighName = educationLevelHigh.Name,
|
|
||||||
CreatedAt = DateTime.Now,
|
CreatedAt = DateTime.Now,
|
||||||
CreatedUserId = UserId ?? "",
|
CreatedUserId = UserId ?? "",
|
||||||
CreatedFullName = FullName ?? "",
|
CreatedFullName = FullName ?? "",
|
||||||
|
|
@ -1111,23 +1119,61 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
||||||
LastUpdateUserId = UserId ?? "",
|
LastUpdateUserId = UserId ?? "",
|
||||||
LastUpdateFullName = FullName ?? "",
|
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);
|
await _context.Educations.AddAsync(education);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
candidate.Educations.FirstOrDefault().EducationLevelExamId = educationLevelExam.Id;
|
|
||||||
candidate.Educations.FirstOrDefault().EducationLevelExamName = educationLevelExam.Name;
|
|
||||||
candidate.Educations.FirstOrDefault().EducationName = updated.EducationName;
|
candidate.Educations.FirstOrDefault().EducationName = updated.EducationName;
|
||||||
candidate.Educations.FirstOrDefault().EducationMajor = updated.EducationMajor;
|
candidate.Educations.FirstOrDefault().EducationMajor = updated.EducationMajor;
|
||||||
candidate.Educations.FirstOrDefault().EducationLocation = updated.EducationLocation;
|
candidate.Educations.FirstOrDefault().EducationLocation = updated.EducationLocation;
|
||||||
candidate.Educations.FirstOrDefault().EducationType = updated.EducationType;
|
candidate.Educations.FirstOrDefault().EducationType = updated.EducationType;
|
||||||
candidate.Educations.FirstOrDefault().EducationEndDate = updated.EducationEndDate;
|
candidate.Educations.FirstOrDefault().EducationEndDate = updated.EducationEndDate;
|
||||||
candidate.Educations.FirstOrDefault().EducationScores = updated.EducationScores;
|
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().LastUpdatedAt = DateTime.Now;
|
||||||
candidate.Educations.FirstOrDefault().LastUpdateUserId = UserId ?? "";
|
candidate.Educations.FirstOrDefault().LastUpdateUserId = UserId ?? "";
|
||||||
candidate.Educations.FirstOrDefault().LastUpdateFullName = FullName ?? "";
|
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();
|
await _context.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
|
|
@ -1615,32 +1661,17 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
||||||
if (candidate == null)
|
if (candidate == null)
|
||||||
throw new Exception(GlobalMessages.CandidateNotFound);
|
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)
|
if (candidate.Educations.FirstOrDefault() == null)
|
||||||
{
|
{
|
||||||
var education = new Education
|
var education = new Education
|
||||||
{
|
{
|
||||||
Candidate = candidate,
|
Candidate = candidate,
|
||||||
EducationLevelExamId = educationLevelExam.Id,
|
|
||||||
EducationLevelExamName = educationLevelExam.Name,
|
|
||||||
EducationName = updated.EducationName,
|
EducationName = updated.EducationName,
|
||||||
EducationMajor = updated.EducationMajor,
|
EducationMajor = updated.EducationMajor,
|
||||||
EducationLocation = updated.EducationLocation,
|
EducationLocation = updated.EducationLocation,
|
||||||
EducationType = updated.EducationType,
|
EducationType = updated.EducationType,
|
||||||
EducationEndDate = updated.EducationEndDate,
|
EducationEndDate = updated.EducationEndDate,
|
||||||
EducationScores = updated.EducationScores,
|
EducationScores = updated.EducationScores,
|
||||||
EducationLevelHighId = educationLevelHigh.Id,
|
|
||||||
EducationLevelHighName = educationLevelHigh.Name,
|
|
||||||
CreatedAt = DateTime.Now,
|
CreatedAt = DateTime.Now,
|
||||||
CreatedUserId = UserId ?? "",
|
CreatedUserId = UserId ?? "",
|
||||||
CreatedFullName = FullName ?? "",
|
CreatedFullName = FullName ?? "",
|
||||||
|
|
@ -1648,23 +1679,61 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
||||||
LastUpdateUserId = UserId ?? "",
|
LastUpdateUserId = UserId ?? "",
|
||||||
LastUpdateFullName = FullName ?? "",
|
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);
|
await _context.Educations.AddAsync(education);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
candidate.Educations.FirstOrDefault().EducationLevelExamId = educationLevelExam.Id;
|
|
||||||
candidate.Educations.FirstOrDefault().EducationLevelExamName = educationLevelExam.Name;
|
|
||||||
candidate.Educations.FirstOrDefault().EducationName = updated.EducationName;
|
candidate.Educations.FirstOrDefault().EducationName = updated.EducationName;
|
||||||
candidate.Educations.FirstOrDefault().EducationMajor = updated.EducationMajor;
|
candidate.Educations.FirstOrDefault().EducationMajor = updated.EducationMajor;
|
||||||
candidate.Educations.FirstOrDefault().EducationLocation = updated.EducationLocation;
|
candidate.Educations.FirstOrDefault().EducationLocation = updated.EducationLocation;
|
||||||
candidate.Educations.FirstOrDefault().EducationType = updated.EducationType;
|
candidate.Educations.FirstOrDefault().EducationType = updated.EducationType;
|
||||||
candidate.Educations.FirstOrDefault().EducationEndDate = updated.EducationEndDate;
|
candidate.Educations.FirstOrDefault().EducationEndDate = updated.EducationEndDate;
|
||||||
candidate.Educations.FirstOrDefault().EducationScores = updated.EducationScores;
|
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().LastUpdatedAt = DateTime.Now;
|
||||||
candidate.Educations.FirstOrDefault().LastUpdateUserId = UserId ?? "";
|
candidate.Educations.FirstOrDefault().LastUpdateUserId = UserId ?? "";
|
||||||
candidate.Educations.FirstOrDefault().LastUpdateFullName = FullName ?? "";
|
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();
|
await _context.SaveChangesAsync();
|
||||||
|
|
@ -1678,32 +1747,17 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
||||||
if (candidate == null)
|
if (candidate == null)
|
||||||
throw new Exception(GlobalMessages.CandidateNotFound);
|
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)
|
if (candidate.Educations.FirstOrDefault() == null)
|
||||||
{
|
{
|
||||||
var education = new Education
|
var education = new Education
|
||||||
{
|
{
|
||||||
Candidate = candidate,
|
Candidate = candidate,
|
||||||
EducationLevelExamId = educationLevelExam.Id,
|
|
||||||
EducationLevelExamName = educationLevelExam.Name,
|
|
||||||
EducationName = updated.EducationName,
|
EducationName = updated.EducationName,
|
||||||
EducationMajor = updated.EducationMajor,
|
EducationMajor = updated.EducationMajor,
|
||||||
EducationLocation = updated.EducationLocation,
|
EducationLocation = updated.EducationLocation,
|
||||||
EducationType = updated.EducationType,
|
EducationType = updated.EducationType,
|
||||||
EducationEndDate = updated.EducationEndDate,
|
EducationEndDate = updated.EducationEndDate,
|
||||||
EducationScores = updated.EducationScores,
|
EducationScores = updated.EducationScores,
|
||||||
EducationLevelHighId = educationLevelHigh.Id,
|
|
||||||
EducationLevelHighName = educationLevelHigh.Name,
|
|
||||||
CreatedAt = DateTime.Now,
|
CreatedAt = DateTime.Now,
|
||||||
CreatedUserId = UserId ?? "",
|
CreatedUserId = UserId ?? "",
|
||||||
CreatedFullName = FullName ?? "",
|
CreatedFullName = FullName ?? "",
|
||||||
|
|
@ -1711,23 +1765,61 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
||||||
LastUpdateUserId = UserId ?? "",
|
LastUpdateUserId = UserId ?? "",
|
||||||
LastUpdateFullName = FullName ?? "",
|
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);
|
await _context.Educations.AddAsync(education);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
candidate.Educations.FirstOrDefault().EducationLevelExamId = educationLevelExam.Id;
|
|
||||||
candidate.Educations.FirstOrDefault().EducationLevelExamName = educationLevelExam.Name;
|
|
||||||
candidate.Educations.FirstOrDefault().EducationName = updated.EducationName;
|
candidate.Educations.FirstOrDefault().EducationName = updated.EducationName;
|
||||||
candidate.Educations.FirstOrDefault().EducationMajor = updated.EducationMajor;
|
candidate.Educations.FirstOrDefault().EducationMajor = updated.EducationMajor;
|
||||||
candidate.Educations.FirstOrDefault().EducationLocation = updated.EducationLocation;
|
candidate.Educations.FirstOrDefault().EducationLocation = updated.EducationLocation;
|
||||||
candidate.Educations.FirstOrDefault().EducationType = updated.EducationType;
|
candidate.Educations.FirstOrDefault().EducationType = updated.EducationType;
|
||||||
candidate.Educations.FirstOrDefault().EducationEndDate = updated.EducationEndDate;
|
candidate.Educations.FirstOrDefault().EducationEndDate = updated.EducationEndDate;
|
||||||
candidate.Educations.FirstOrDefault().EducationScores = updated.EducationScores;
|
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().LastUpdatedAt = DateTime.Now;
|
||||||
candidate.Educations.FirstOrDefault().LastUpdateUserId = UserId ?? "";
|
candidate.Educations.FirstOrDefault().LastUpdateUserId = UserId ?? "";
|
||||||
candidate.Educations.FirstOrDefault().LastUpdateFullName = FullName ?? "";
|
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();
|
await _context.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
|
|
@ -2332,6 +2424,76 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
||||||
throw new Exception(GlobalMessages.CitizanDupicate);
|
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
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue