api จัดรอบการสอบ
This commit is contained in:
parent
44d18ff74c
commit
bd0f02feb1
24 changed files with 8532 additions and 33 deletions
|
|
@ -2,6 +2,7 @@
|
|||
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.Request;
|
||||
using BMA.EHR.Recurit.Exam.Service.Response;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
|
|
@ -37,6 +38,30 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
|
||||
#region " Methods "
|
||||
|
||||
public async Task<Candidate> GetsAsync(string candidateId)
|
||||
{
|
||||
var candidate = await _context.Candidates.AsQueryable()
|
||||
.Include(x => x.Prefix)
|
||||
.Include(x => x.Relationship)
|
||||
.Include(x => x.CitizenProvince)
|
||||
.Include(x => x.CitizenDistrict)
|
||||
.Include(x => x.RegistProvince)
|
||||
.Include(x => x.RegistDistrict)
|
||||
.Include(x => x.RegistSubDistrict)
|
||||
.Include(x => x.CurrentProvince)
|
||||
.Include(x => x.CurrentDistrict)
|
||||
.Include(x => x.CurrentSubDistrict)
|
||||
.Include(x => x.MarryPrefix)
|
||||
.Include(x => x.FatherPrefix)
|
||||
.Include(x => x.MotherPrefix)
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(candidateId));
|
||||
|
||||
if (candidate == null)
|
||||
throw new Exception(GlobalMessages.CandidateNotFound);
|
||||
|
||||
return candidate;
|
||||
}
|
||||
|
||||
public async Task<CandidateInformationResponseItem?> GetsAsyncInformation(string examId)
|
||||
{
|
||||
var exam = await _context.PeriodExams.AsQueryable()
|
||||
|
|
@ -121,14 +146,20 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
MarryPrefixId = x.MarryPrefix != null ? x.MarryPrefix.Id.ToString() : null,
|
||||
MarryFirstName = x.MarryFirstName,
|
||||
MarryLastName = x.MarryLastName,
|
||||
MarryOccupation = x.MarryOccupation,
|
||||
MarryNationality = x.MarryNationality,
|
||||
FatherPrefix = x.FatherPrefix,
|
||||
FatherPrefixId = x.FatherPrefix != null ? x.FatherPrefix.Id.ToString() : null,
|
||||
FatherFirstName = x.FatherFirstName,
|
||||
FatherLastName = x.FatherLastName,
|
||||
FatherOccupation = x.FatherOccupation,
|
||||
FatherNationality = x.FatherNationality,
|
||||
MotherPrefix = x.MotherPrefix,
|
||||
MotherPrefixId = x.MotherPrefix != null ? x.MotherPrefix.Id.ToString() : null,
|
||||
MotherFirstName = x.MotherFirstName,
|
||||
MotherLastName = x.MotherLastName,
|
||||
MotherOccupation = x.MotherOccupation,
|
||||
MotherNationality = x.MotherNationality,
|
||||
})
|
||||
.FirstOrDefaultAsync();
|
||||
}
|
||||
|
|
@ -150,6 +181,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
OccupationDepartment = x.OccupationDepartment,
|
||||
OccupationEmail = x.OccupationEmail,
|
||||
OccupationTelephone = x.OccupationTelephone,
|
||||
OccupationPosition = x.OccupationPosition,
|
||||
})
|
||||
.FirstOrDefaultAsync();
|
||||
}
|
||||
|
|
@ -163,7 +195,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
throw new Exception(GlobalMessages.ExamNotFound);
|
||||
|
||||
var candidate = await _context.Candidates.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(examId) && x.UserId == UserId);
|
||||
.FirstOrDefaultAsync(x => x.PeriodExam == exam && x.UserId == UserId);
|
||||
|
||||
return await _context.Careers.AsQueryable()
|
||||
.Where(x => x.Candidate == candidate)
|
||||
|
|
@ -180,9 +212,10 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
throw new Exception(GlobalMessages.ExamNotFound);
|
||||
|
||||
var candidate = await _context.Candidates.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(examId) && x.UserId == UserId);
|
||||
.FirstOrDefaultAsync(x => x.PeriodExam == exam && x.UserId == UserId);
|
||||
|
||||
return await _context.Educations.AsQueryable()
|
||||
.Include(x => x.EducationLevel)
|
||||
.Where(x => x.Candidate == candidate)
|
||||
.OrderBy(d => d.DurationStart)
|
||||
.ToListAsync();
|
||||
|
|
@ -197,7 +230,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
throw new Exception(GlobalMessages.ExamNotFound);
|
||||
|
||||
var candidate = await _context.Candidates.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(examId) && x.UserId == UserId);
|
||||
.FirstOrDefaultAsync(x => x.PeriodExam == exam && x.UserId == UserId);
|
||||
|
||||
return candidate != null;
|
||||
}
|
||||
|
|
@ -427,10 +460,16 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
candidate.Marry = 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;
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
|
@ -450,6 +489,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
candidate.OccupationDepartment = updated.OccupationDepartment;
|
||||
candidate.OccupationEmail = updated.OccupationEmail;
|
||||
candidate.OccupationTelephone = updated.OccupationTelephone;
|
||||
candidate.OccupationPosition = updated.OccupationPosition;
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
|
@ -539,6 +579,19 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task DeleteAsyncCareer(string careerId)
|
||||
{
|
||||
var career = await _context.Careers.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(careerId));
|
||||
|
||||
if (career == null)
|
||||
throw new Exception(GlobalMessages.CareerNotFound);
|
||||
|
||||
_context.Careers.Remove(career);
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task UpdateAsyncEducation(string educationId, CandidateEducationResponseItem updated)
|
||||
{
|
||||
var education = await _context.Educations.AsQueryable()
|
||||
|
|
@ -566,6 +619,19 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task DeleteAsyncEducation(string educationId)
|
||||
{
|
||||
var education = await _context.Educations.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(educationId));
|
||||
|
||||
if (education == null)
|
||||
throw new Exception(GlobalMessages.EducationNotFound);
|
||||
|
||||
_context.Educations.Remove(education);
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task<string> GetStatusCandidateService(string examId)
|
||||
{
|
||||
var exam = await _context.PeriodExams.AsQueryable()
|
||||
|
|
@ -580,7 +646,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
if (candidate == null)
|
||||
throw new Exception(GlobalMessages.CandidateNotFound);
|
||||
|
||||
return candidate.status;
|
||||
return candidate.Status;
|
||||
}
|
||||
|
||||
public async Task UserCheckCandidateService(string examId, string status)
|
||||
|
|
@ -597,12 +663,12 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
if (candidate == null)
|
||||
throw new Exception(GlobalMessages.CandidateNotFound);
|
||||
|
||||
candidate.status = status;
|
||||
candidate.Status = status;
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task AdminCheckCandidateService(string candidateId, string status)
|
||||
public async Task AdminCheckCandidateService(string candidateId, string status, RequestApprove item)
|
||||
{
|
||||
var candidate = await _context.Candidates.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(candidateId));
|
||||
|
|
@ -610,7 +676,31 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
if (candidate == null)
|
||||
throw new Exception(GlobalMessages.CandidateNotFound);
|
||||
|
||||
candidate.status = status;
|
||||
if (status != "rejectDelete")
|
||||
{
|
||||
candidate.Status = status;
|
||||
if (status == "rejectRegister" || status == "rejectPayment")
|
||||
{
|
||||
candidate.RejectDetail = item.Reason;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_context.Candidates.Remove(candidate);
|
||||
}
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task AdminPassCandidateService(string candidateId, string status)
|
||||
{
|
||||
var candidate = await _context.Candidates.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(candidateId));
|
||||
|
||||
if (candidate == null)
|
||||
throw new Exception(GlobalMessages.CandidateNotFound);
|
||||
|
||||
candidate.Status = status;
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,16 +49,29 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<PeriodExam?> GetsExamAndCandidateAsync(string id, bool showAll = true)
|
||||
public async Task<PeriodExam?> GetsExamAndCandidateAsync(string examId, bool showAll = true)
|
||||
{
|
||||
return await _context.PeriodExams.FirstOrDefaultAsync(x => x.Id == Guid.Parse(id));
|
||||
var periodExam = await _context.PeriodExams.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(examId));
|
||||
|
||||
if (periodExam == null)
|
||||
throw new Exception(GlobalMessages.ExamNotFound);
|
||||
|
||||
return periodExam;
|
||||
}
|
||||
|
||||
public async Task CreateAsync(PeriodExam inserted)
|
||||
{
|
||||
var periodExam = new PeriodExam
|
||||
{
|
||||
//xxxxxxxxxxxxxxxxxxxxxxx
|
||||
Name = inserted.Name,
|
||||
StartDate = inserted.StartDate,
|
||||
EndDate = inserted.EndDate,
|
||||
Round = inserted.Round,
|
||||
Fee = inserted.Fee,
|
||||
Year = inserted.Year,
|
||||
Detail = inserted.Detail,
|
||||
AnnounceDate = inserted.AnnounceDate,
|
||||
CreatedAt = DateTime.Now,
|
||||
CreatedUserId = UserId ?? "",
|
||||
LastUpdatedAt = DateTime.Now,
|
||||
|
|
@ -80,7 +93,14 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
if (periodExam == null)
|
||||
throw new Exception(GlobalMessages.ExamNotFound);
|
||||
|
||||
//xxxxxxxxxxxxxxxxxxxxx
|
||||
periodExam.Name = updated.Name;
|
||||
periodExam.StartDate = updated.StartDate;
|
||||
periodExam.EndDate = updated.EndDate;
|
||||
periodExam.Round = updated.Round;
|
||||
periodExam.Fee = updated.Fee;
|
||||
periodExam.Year = updated.Year;
|
||||
periodExam.Detail = updated.Detail;
|
||||
periodExam.AnnounceDate = updated.AnnounceDate;
|
||||
periodExam.IsActive = updated.IsActive;
|
||||
periodExam.LastUpdatedAt = DateTime.Now;
|
||||
periodExam.LastUpdateUserId = UserId ?? "";
|
||||
|
|
@ -101,6 +121,19 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<Candidate?>> GetsCandidateByStatusAsync(string examId, string status)
|
||||
{
|
||||
var periodExam = await _context.PeriodExams.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(examId));
|
||||
|
||||
if (periodExam == null)
|
||||
throw new Exception(GlobalMessages.ExamNotFound);
|
||||
|
||||
return await _context.Candidates.AsQueryable()
|
||||
.Where(x => x.PeriodExam == periodExam && x.Status == status)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue