api บันทึก และ แสดง ข้อมูลผู้สมัคร
This commit is contained in:
parent
ffeab6a127
commit
a781c375d7
40 changed files with 10433 additions and 2 deletions
567
Services/CandidateService.cs
Normal file
567
Services/CandidateService.cs
Normal file
|
|
@ -0,0 +1,567 @@
|
|||
using System.Security.Claims;
|
||||
using BMA.EHR.Recurit.Exam.Service.Core;
|
||||
using BMA.EHR.Recurit.Exam.Service.Data;
|
||||
using BMA.EHR.Recurit.Exam.Service.Models;
|
||||
using BMA.EHR.Recurit.Exam.Service.Response;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace BMA.EHR.Recurit.Exam.Service.Services
|
||||
{
|
||||
public class CandidateService
|
||||
{
|
||||
#region " Fields "
|
||||
|
||||
private readonly ApplicationDbContext _context;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
|
||||
#endregion
|
||||
|
||||
#region " Constructor and Destructor "
|
||||
|
||||
public CandidateService(ApplicationDbContext context,
|
||||
IHttpContextAccessor httpContextAccessor)
|
||||
{
|
||||
_context = context;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region " Properties "
|
||||
|
||||
private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
|
||||
|
||||
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
|
||||
|
||||
#endregion
|
||||
|
||||
#region " Methods "
|
||||
|
||||
public async Task<CandidateInformationResponseItem?> GetsAsyncInformation(string examId)
|
||||
{
|
||||
var exam = await _context.PeriodExams.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(examId));
|
||||
|
||||
if (exam == null)
|
||||
throw new Exception(GlobalMessages.ExamNotFound);
|
||||
|
||||
return await _context.Candidates.AsQueryable()
|
||||
.Where(x => x.PeriodExam == exam && x.UserId == UserId)
|
||||
.Select(x => new CandidateInformationResponseItem
|
||||
{
|
||||
Prefix = x.Prefix,
|
||||
FirstName = x.FirstName,
|
||||
LastName = x.LastName,
|
||||
Nationality = x.Nationality,
|
||||
DateOfBirth = x.DateOfBirth,
|
||||
Relationship = x.Relationship,
|
||||
Email = x.Email,
|
||||
CitizenId = x.CitizenId,
|
||||
})
|
||||
.FirstOrDefaultAsync();
|
||||
}
|
||||
|
||||
public async Task<CandidateAddressResponseItem?> GetsAsyncAddress(string examId)
|
||||
{
|
||||
var exam = await _context.PeriodExams.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(examId));
|
||||
|
||||
if (exam == null)
|
||||
throw new Exception(GlobalMessages.ExamNotFound);
|
||||
|
||||
return await _context.Candidates.AsQueryable()
|
||||
.Where(x => x.PeriodExam == exam && x.UserId == UserId)
|
||||
.Select(x => new CandidateAddressResponseItem
|
||||
{
|
||||
RegistAddress = x.RegistAddress,
|
||||
RegistProvince = x.RegistProvince,
|
||||
RegistDistrict = x.RegistDistrict,
|
||||
RegistSubDistrict = x.RegistSubDistrict,
|
||||
RegistZipCode = x.RegistZipCode,
|
||||
RegistSame = x.RegistSame,
|
||||
CurrentAddress = x.CurrentAddress,
|
||||
CurrentProvince = x.CurrentProvince,
|
||||
CurrentDistrict = x.CurrentDistrict,
|
||||
CurrentSubDistrict = x.CurrentSubDistrict,
|
||||
CurrentZipCode = x.CurrentZipCode,
|
||||
})
|
||||
.FirstOrDefaultAsync();
|
||||
}
|
||||
|
||||
public async Task<CandidateFamilyResponseItem?> GetsAsyncFamily(string examId)
|
||||
{
|
||||
var exam = await _context.PeriodExams.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(examId));
|
||||
|
||||
if (exam == null)
|
||||
throw new Exception(GlobalMessages.ExamNotFound);
|
||||
|
||||
return await _context.Candidates.AsQueryable()
|
||||
.Where(x => x.PeriodExam == exam && x.UserId == UserId)
|
||||
.Select(x => new CandidateFamilyResponseItem
|
||||
{
|
||||
Marry = x.Marry,
|
||||
MarryPrefix = x.MarryPrefix,
|
||||
MarryFirstName = x.MarryFirstName,
|
||||
MarryLastName = x.MarryLastName,
|
||||
FatherPrefix = x.FatherPrefix,
|
||||
FatherFirstName = x.FatherFirstName,
|
||||
FatherLastName = x.FatherLastName,
|
||||
MotherPrefix = x.MotherPrefix,
|
||||
MotherFirstName = x.MotherFirstName,
|
||||
MotherLastName = x.MotherLastName,
|
||||
})
|
||||
.FirstOrDefaultAsync();
|
||||
}
|
||||
|
||||
public async Task<CandidateOccupationResponseItem?> GetsAsyncOccupation(string examId)
|
||||
{
|
||||
var exam = await _context.PeriodExams.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(examId));
|
||||
|
||||
if (exam == null)
|
||||
throw new Exception(GlobalMessages.ExamNotFound);
|
||||
|
||||
return await _context.Candidates.AsQueryable()
|
||||
.Where(x => x.PeriodExam == exam && x.UserId == UserId)
|
||||
.Select(x => new CandidateOccupationResponseItem
|
||||
{
|
||||
OccupationType = x.OccupationType,
|
||||
OccupationCompany = x.OccupationCompany,
|
||||
OccupationDepartment = x.OccupationDepartment,
|
||||
OccupationEmail = x.OccupationEmail,
|
||||
OccupationTelephone = x.OccupationTelephone,
|
||||
})
|
||||
.FirstOrDefaultAsync();
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<Career?>> GetsAsyncCareer(string examId)
|
||||
{
|
||||
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.Id == Guid.Parse(examId) && x.UserId == UserId);
|
||||
|
||||
return await _context.Careers.AsQueryable()
|
||||
.Where(x => x.Candidate == candidate)
|
||||
.OrderBy(d => d.DurationStart)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<Education?>> GetsAsyncEducation(string examId)
|
||||
{
|
||||
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.Id == Guid.Parse(examId) && x.UserId == UserId);
|
||||
|
||||
return await _context.Educations.AsQueryable()
|
||||
.Where(x => x.Candidate == candidate)
|
||||
.OrderBy(d => d.DurationStart)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<bool> GetsAsyncRegisterExam(string examId)
|
||||
{
|
||||
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.Id == Guid.Parse(examId) && x.UserId == UserId);
|
||||
|
||||
return candidate != null;
|
||||
}
|
||||
|
||||
public async Task<string> CreateAsyncCandidate(string examId)
|
||||
{
|
||||
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)
|
||||
{
|
||||
var candidate = new Candidate
|
||||
{
|
||||
PeriodExam = exam,
|
||||
CreatedAt = DateTime.Now,
|
||||
CreatedUserId = UserId ?? "",
|
||||
LastUpdatedAt = DateTime.Now,
|
||||
LastUpdateUserId = UserId ?? "",
|
||||
CreatedFullName = FullName ?? "",
|
||||
LastUpdateFullName = FullName ?? "",
|
||||
UserId = UserId ?? "",
|
||||
};
|
||||
|
||||
await _context.Candidates.AddAsync(candidate);
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return candidate.Id.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
_candidate.LastUpdatedAt = DateTime.Now;
|
||||
_candidate.LastUpdateUserId = UserId ?? "";
|
||||
_candidate.LastUpdateFullName = FullName ?? "";
|
||||
return _candidate.Id.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
public async Task UpdateAsyncInformation(string examId, CandidateInformationResponseItem 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;
|
||||
}
|
||||
|
||||
candidate.FirstName = updated.FirstName;
|
||||
candidate.LastName = updated.LastName;
|
||||
candidate.Nationality = updated.Nationality;
|
||||
candidate.DateOfBirth = updated.DateOfBirth;
|
||||
candidate.Email = updated.Email;
|
||||
candidate.CitizenId = updated.CitizenId;
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task UpdateAsyncAddress(string examId, CandidateAddressResponseItem 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.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.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.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;
|
||||
}
|
||||
|
||||
candidate.RegistAddress = updated.RegistAddress;
|
||||
candidate.RegistSame = updated.RegistSame;
|
||||
candidate.CurrentAddress = updated.CurrentAddress;
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task UpdateAsyncFamily(string examId, CandidateFamilyResponseItem 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.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.Marry = updated.Marry;
|
||||
candidate.MarryFirstName = updated.MarryFirstName;
|
||||
candidate.MarryLastName = updated.MarryLastName;
|
||||
candidate.FatherFirstName = updated.FatherFirstName;
|
||||
candidate.FatherLastName = updated.FatherLastName;
|
||||
candidate.MotherFirstName = updated.MotherFirstName;
|
||||
candidate.MotherLastName = updated.MotherLastName;
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task UpdateAsyncOccupation(string examId, CandidateOccupationResponseItem 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);
|
||||
|
||||
candidate.OccupationType = updated.OccupationType;
|
||||
candidate.OccupationCompany = updated.OccupationCompany;
|
||||
candidate.OccupationDepartment = updated.OccupationDepartment;
|
||||
candidate.OccupationEmail = updated.OccupationEmail;
|
||||
candidate.OccupationTelephone = updated.OccupationTelephone;
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task CreateAsyncCareer(string examId, CandidateCareerResponseItem updated)
|
||||
{
|
||||
var candidateId = await CreateAsyncCandidate(examId);
|
||||
|
||||
var candidate = await _context.Candidates.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(candidateId));
|
||||
|
||||
var career = new Career
|
||||
{
|
||||
Candidate = candidate,
|
||||
Name = updated.Name,
|
||||
Position = updated.Position,
|
||||
Salary = updated.Salary,
|
||||
DurationStart = updated.DurationStart,
|
||||
DurationEnd = updated.DurationEnd,
|
||||
Reason = updated.Reason,
|
||||
CreatedAt = DateTime.Now,
|
||||
CreatedUserId = UserId ?? "",
|
||||
LastUpdatedAt = DateTime.Now,
|
||||
LastUpdateUserId = UserId ?? "",
|
||||
CreatedFullName = FullName ?? "",
|
||||
LastUpdateFullName = FullName ?? "",
|
||||
};
|
||||
|
||||
await _context.Careers.AddAsync(career);
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task CreateAsyncEducation(string examId, CandidateEducationResponseItem updated)
|
||||
{
|
||||
var candidateId = await CreateAsyncCandidate(examId);
|
||||
|
||||
var candidate = await _context.Candidates.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(candidateId));
|
||||
|
||||
var educationLevel = await _context.EducationLevels.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(updated.EducationLevelId));
|
||||
|
||||
if (educationLevel == null)
|
||||
throw new Exception(GlobalMessages.EducationLevelNotFound);
|
||||
|
||||
var education = new Education
|
||||
{
|
||||
Candidate = candidate,
|
||||
EducationLevel = educationLevel,
|
||||
Major = updated.Major,
|
||||
Scores = updated.Scores,
|
||||
Name = updated.Name,
|
||||
DurationStart = updated.DurationStart,
|
||||
DurationEnd = updated.DurationEnd,
|
||||
CreatedAt = DateTime.Now,
|
||||
CreatedUserId = UserId ?? "",
|
||||
LastUpdatedAt = DateTime.Now,
|
||||
LastUpdateUserId = UserId ?? "",
|
||||
CreatedFullName = FullName ?? "",
|
||||
LastUpdateFullName = FullName ?? "",
|
||||
};
|
||||
|
||||
await _context.Educations.AddAsync(education);
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task UpdateAsyncCareer(string careerId, CandidateCareerResponseItem updated)
|
||||
{
|
||||
var career = await _context.Careers.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(careerId));
|
||||
|
||||
if (career == null)
|
||||
throw new Exception(GlobalMessages.CareerNotFound);
|
||||
|
||||
career.Name = updated.Name;
|
||||
career.Position = updated.Position;
|
||||
career.Salary = updated.Salary;
|
||||
career.DurationStart = updated.DurationStart;
|
||||
career.DurationEnd = updated.DurationEnd;
|
||||
career.Reason = updated.Reason;
|
||||
career.LastUpdatedAt = DateTime.Now;
|
||||
career.LastUpdateUserId = UserId ?? "";
|
||||
career.LastUpdateFullName = FullName ?? "";
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task UpdateAsyncEducation(string educationId, CandidateEducationResponseItem updated)
|
||||
{
|
||||
var education = await _context.Educations.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(educationId));
|
||||
|
||||
if (education == null)
|
||||
throw new Exception(GlobalMessages.EducationNotFound);
|
||||
|
||||
var educationLevel = await _context.EducationLevels.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(updated.EducationLevelId));
|
||||
|
||||
if (educationLevel == null)
|
||||
throw new Exception(GlobalMessages.EducationLevelNotFound);
|
||||
|
||||
education.EducationLevel = educationLevel;
|
||||
education.Major = updated.Major;
|
||||
education.Scores = updated.Scores;
|
||||
education.Name = updated.Name;
|
||||
education.DurationStart = updated.DurationStart;
|
||||
education.DurationEnd = updated.DurationEnd;
|
||||
education.LastUpdatedAt = DateTime.Now;
|
||||
education.LastUpdateUserId = UserId ?? "";
|
||||
education.LastUpdateFullName = FullName ?? "";
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task RegisterCandidateService(string examId)
|
||||
{
|
||||
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 = "registered";
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue