บันทึกข้อมูลสมัครสอบทั้งหมดรวมเป็น1api
This commit is contained in:
parent
2328f19be4
commit
4c3b15c72b
3 changed files with 279 additions and 0 deletions
|
|
@ -267,6 +267,32 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// อัพเดทข้อมูล ข้อมูลส่วนตัว ผู้สมัคร
|
||||
/// </summary>
|
||||
/// <param name="candidateInformation">ข้อมูลส่วนตัว</param>
|
||||
/// <returns></returns>
|
||||
/// <response code="200">เมื่อทำการอัพเดทข้อมูล ข้อมูลส่วนตัว ผู้สมัคร สำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("{examId:length(36)}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> UpdateAsync(string examId, CandidateResponseItem candidateInformation)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _candidateService.UpdateAsync(examId, candidateInformation);
|
||||
|
||||
return Success();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Error(ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// อัพเดทข้อมูล ข้อมูลส่วนตัว ผู้สมัคร
|
||||
/// </summary>
|
||||
|
|
|
|||
72
Response/CandidateResponseItem.cs
Normal file
72
Response/CandidateResponseItem.cs
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
|
||||
namespace BMA.EHR.Recurit.Exam.Service.Response
|
||||
{
|
||||
public class CandidateResponseItem
|
||||
{
|
||||
public Models.Prefix? Prefix { get; set; }
|
||||
public string? PrefixId { get; set; }
|
||||
public string? FirstName { get; set; } = string.Empty;
|
||||
public string? LastName { get; set; } = string.Empty;
|
||||
public string? Nationality { get; set; } = string.Empty;
|
||||
public DateTime? DateOfBirth { get; set; }
|
||||
public Models.Relationship? Relationship { get; set; }
|
||||
public string? RelationshipId { get; set; }
|
||||
public string? Email { get; set; } = string.Empty;
|
||||
public string? CitizenId { get; set; } = string.Empty;
|
||||
public Models.Province? CitizenProvince { get; set; }
|
||||
public string? CitizenProvinceId { get; set; }
|
||||
public Models.District? CitizenDistrict { get; set; }
|
||||
public string? CitizenDistrictId { get; set; }
|
||||
public DateTime? CitizenDate { get; set; }
|
||||
public string? Telephone { get; set; }
|
||||
public string? MobilePhone { get; set; }
|
||||
public string? Knowledge { get; set; }
|
||||
public string? RegistAddress { get; set; }
|
||||
public Models.Province? RegistProvince { get; set; }
|
||||
public string? RegistProvinceId { get; set; }
|
||||
public Models.District? RegistDistrict { get; set; }
|
||||
public string? RegistDistrictId { get; set; }
|
||||
public Models.SubDistrict? RegistSubDistrict { get; set; }
|
||||
public string? RegistSubDistrictId { get; set; }
|
||||
public string? RegistZipCode { get; set; }
|
||||
public bool? RegistSame { get; set; }
|
||||
public string? CurrentAddress { get; set; }
|
||||
public Models.Province? CurrentProvince { get; set; }
|
||||
public string? CurrentProvinceId { get; set; }
|
||||
public Models.District? CurrentDistrict { get; set; }
|
||||
public string? CurrentDistrictId { get; set; }
|
||||
public Models.SubDistrict? CurrentSubDistrict { get; set; }
|
||||
public string? CurrentSubDistrictId { get; set; }
|
||||
public string? CurrentZipCode { get; set; }
|
||||
public bool? Marry { get; set; }
|
||||
public Models.Prefix? MarryPrefix { get; set; }
|
||||
public string? MarryPrefixId { get; set; }
|
||||
public string? MarryFirstName { get; set; }
|
||||
public string? MarryLastName { get; set; }
|
||||
public string? MarryOccupation { get; set; }
|
||||
public string? MarryNationality { get; set; }
|
||||
public Models.Prefix? FatherPrefix { get; set; }
|
||||
public string? FatherPrefixId { get; set; }
|
||||
public string? FatherFirstName { get; set; }
|
||||
public string? FatherLastName { get; set; }
|
||||
public string? FatherOccupation { get; set; }
|
||||
public string? FatherNationality { get; set; }
|
||||
public Models.Prefix? MotherPrefix { get; set; }
|
||||
public string? MotherPrefixId { get; set; }
|
||||
public string? MotherFirstName { get; set; }
|
||||
public string? MotherLastName { get; set; }
|
||||
public string? MotherOccupation { get; set; }
|
||||
public string? MotherNationality { get; set; }
|
||||
public string? OccupationType { get; set; }
|
||||
|
||||
public string? OccupationCompany { get; set; }
|
||||
|
||||
public string? OccupationDepartment { get; set; }
|
||||
|
||||
public string? OccupationEmail { get; set; }
|
||||
|
||||
public string? OccupationTelephone { get; set; }
|
||||
|
||||
public string? OccupationPosition { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -278,6 +278,187 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
}
|
||||
}
|
||||
|
||||
public async Task UpdateAsync(string examId, CandidateResponseItem updated)
|
||||
{
|
||||
var candidateId = await CreateAsyncCandidate(examId);
|
||||
|
||||
var candidate = await _context.Candidates.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(candidateId));
|
||||
|
||||
if (candidate == null)
|
||||
throw new Exception(GlobalMessages.ExamNotFound);
|
||||
|
||||
if (updated.PrefixId != null)
|
||||
{
|
||||
var prefix = await _context.Prefixes.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(updated.PrefixId));
|
||||
|
||||
if (prefix == null)
|
||||
throw new Exception(GlobalMessages.PrefixNotFound);
|
||||
candidate.Prefix = prefix;
|
||||
}
|
||||
|
||||
if (updated.RelationshipId != null)
|
||||
{
|
||||
var relationship = await _context.Relationships.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(updated.RelationshipId));
|
||||
|
||||
if (relationship == null)
|
||||
throw new Exception(GlobalMessages.RelationshipNotFound);
|
||||
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;
|
||||
}
|
||||
|
||||
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()
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(updated.RegistDistrictId));
|
||||
|
||||
if (registDistrict == null)
|
||||
throw new Exception(GlobalMessages.DistrictNotFound);
|
||||
candidate.RegistDistrict = registDistrict;
|
||||
}
|
||||
|
||||
if (updated.RegistSubDistrictId != null)
|
||||
{
|
||||
var registSubDistrict = await _context.SubDistricts.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(updated.RegistSubDistrictId));
|
||||
|
||||
if (registSubDistrict == null)
|
||||
throw new Exception(GlobalMessages.SubDistrictNotFound);
|
||||
candidate.RegistSubDistrict = registSubDistrict;
|
||||
candidate.RegistZipCode = registSubDistrict.ZipCode;
|
||||
}
|
||||
|
||||
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()
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(updated.CurrentDistrictId));
|
||||
|
||||
if (currentDistrict == null)
|
||||
throw new Exception(GlobalMessages.DistrictNotFound);
|
||||
candidate.CurrentDistrict = currentDistrict;
|
||||
}
|
||||
|
||||
if (updated.CurrentSubDistrictId != null)
|
||||
{
|
||||
var currentSubDistrict = await _context.SubDistricts.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(updated.CurrentSubDistrictId));
|
||||
|
||||
if (currentSubDistrict == null)
|
||||
throw new Exception(GlobalMessages.SubDistrictNotFound);
|
||||
candidate.CurrentSubDistrict = currentSubDistrict;
|
||||
candidate.CurrentZipCode = currentSubDistrict.ZipCode;
|
||||
}
|
||||
|
||||
if (updated.MarryPrefixId != null)
|
||||
{
|
||||
var prefix = await _context.Prefixes.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(updated.MarryPrefixId));
|
||||
|
||||
if (prefix == null)
|
||||
throw new Exception(GlobalMessages.PrefixNotFound);
|
||||
candidate.MarryPrefix = prefix;
|
||||
}
|
||||
|
||||
if (updated.FatherPrefixId != null)
|
||||
{
|
||||
var prefix = await _context.Prefixes.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(updated.FatherPrefixId));
|
||||
|
||||
if (prefix == null)
|
||||
throw new Exception(GlobalMessages.PrefixNotFound);
|
||||
candidate.FatherPrefix = prefix;
|
||||
}
|
||||
|
||||
if (updated.MotherPrefixId != null)
|
||||
{
|
||||
var prefix = await _context.Prefixes.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(updated.MotherPrefixId));
|
||||
|
||||
if (prefix == null)
|
||||
throw new Exception(GlobalMessages.PrefixNotFound);
|
||||
candidate.MotherPrefix = prefix;
|
||||
}
|
||||
|
||||
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;
|
||||
candidate.Telephone = updated.Telephone;
|
||||
candidate.MobilePhone = updated.MobilePhone;
|
||||
candidate.Knowledge = updated.Knowledge;
|
||||
|
||||
candidate.RegistAddress = updated.RegistAddress;
|
||||
candidate.RegistSame = updated.RegistSame == null ? null : updated.RegistSame;
|
||||
candidate.CurrentAddress = updated.CurrentAddress;
|
||||
|
||||
candidate.Marry = updated.Marry == null ? null : updated.Marry;
|
||||
candidate.MarryFirstName = updated.MarryFirstName;
|
||||
candidate.MarryLastName = updated.MarryLastName;
|
||||
candidate.MarryOccupation = updated.MarryOccupation;
|
||||
candidate.MarryNationality = updated.MarryNationality;
|
||||
candidate.FatherFirstName = updated.FatherFirstName;
|
||||
candidate.FatherLastName = updated.FatherLastName;
|
||||
candidate.FatherOccupation = updated.FatherOccupation;
|
||||
candidate.FatherNationality = updated.FatherNationality;
|
||||
candidate.MotherFirstName = updated.MotherFirstName;
|
||||
candidate.MotherLastName = updated.MotherLastName;
|
||||
candidate.MotherOccupation = updated.MotherOccupation;
|
||||
candidate.MotherNationality = updated.MotherNationality;
|
||||
|
||||
candidate.OccupationType = updated.OccupationType;
|
||||
candidate.OccupationCompany = updated.OccupationCompany;
|
||||
candidate.OccupationDepartment = updated.OccupationDepartment;
|
||||
candidate.OccupationEmail = updated.OccupationEmail;
|
||||
candidate.OccupationTelephone = updated.OccupationTelephone;
|
||||
candidate.OccupationPosition = updated.OccupationPosition;
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task UpdateAsyncInformation(string examId, CandidateInformationResponseItem updated)
|
||||
{
|
||||
var candidateId = await CreateAsyncCandidate(examId);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue