admin แก้ไขสมัครสอบคัดเลือก
This commit is contained in:
parent
0273a37503
commit
ae60457a3e
6 changed files with 986 additions and 289 deletions
|
|
@ -427,6 +427,38 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
return document;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<FileListResponse?>> GetsAsyncAdminFileUpload(string candidateId)
|
||||
{
|
||||
var candidate = await _context.Candidates.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(candidateId));
|
||||
|
||||
if (candidate == null)
|
||||
throw new Exception(GlobalMessages.CandidateNotFound);
|
||||
|
||||
var document = await _context.CandidateDocuments.AsQueryable()
|
||||
.Where(x => x.Candidate == candidate)
|
||||
.OrderBy(x => x.CreatedAt)
|
||||
.Select(x => new FileListResponse
|
||||
{
|
||||
Id = x.Document == null ? "" : x.Document.Id.ToString(),
|
||||
FileName = x.Document == null ? "" : x.Document.FileName,
|
||||
FileType = x.Document == null ? "" : x.Document.FileType,
|
||||
FileSize = x.Document == null ? 0 : x.Document.FileSize,
|
||||
Detail = x.Document == null ? "" : x.Document.Id.ToString(),
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
var i = 0;
|
||||
foreach (var item in document)
|
||||
{
|
||||
if (document[i].Detail != null && document[i].Detail != "")
|
||||
document[i].Detail = _minioService.ImagesPath(Guid.Parse(document[i].Detail)).Result;
|
||||
i++;
|
||||
}
|
||||
|
||||
return document;
|
||||
}
|
||||
|
||||
public async Task<string> GetsAsyncProfileImage(string examId, string positionId)
|
||||
{
|
||||
var exam = await _context.PeriodExams.AsQueryable()
|
||||
|
|
@ -463,6 +495,21 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
return candidate.ProfileImg == null ? "" : candidate.ProfileImg.Detail;
|
||||
}
|
||||
|
||||
public async Task<string> GetsAsyncAdminProfileImage(string candidateId)
|
||||
{
|
||||
var candidate = await _context.Candidates.AsQueryable()
|
||||
.Include(x => x.ProfileImg)
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(candidateId));
|
||||
|
||||
if (candidate == null)
|
||||
throw new Exception(GlobalMessages.CandidateNotFound);
|
||||
|
||||
if (candidate.ProfileImg != null)
|
||||
candidate.ProfileImg.Detail = _minioService.ImagesPath(candidate.ProfileImg.Id).Result;
|
||||
|
||||
return candidate.ProfileImg == null ? "" : candidate.ProfileImg.Detail;
|
||||
}
|
||||
|
||||
public async Task<PaymentImgResponse> GetsAsyncPaymentImg(string examId, string positionId)
|
||||
{
|
||||
var exam = await _context.PeriodExams.AsQueryable()
|
||||
|
|
@ -815,6 +862,211 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task UpdateAdminAsync(string candidateId, CandidateResponseItem updated)
|
||||
{
|
||||
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 _contextMetadata.Prefixes.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(updated.PrefixId));
|
||||
|
||||
if (prefix == null)
|
||||
throw new Exception(GlobalMessages.PrefixNotFound);
|
||||
|
||||
candidate.PrefixId = prefix.Id;
|
||||
candidate.PrefixName = prefix.Name;
|
||||
}
|
||||
|
||||
if (updated.RelationshipId != null)
|
||||
{
|
||||
var relationship = await _contextMetadata.Relationships.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(updated.RelationshipId));
|
||||
|
||||
if (relationship == null)
|
||||
throw new Exception(GlobalMessages.RelationshipNotFound);
|
||||
|
||||
candidate.RelationshipId = relationship.Id;
|
||||
candidate.RelationshipName = relationship.Name;
|
||||
}
|
||||
|
||||
if (updated.CitizenProvinceId != null)
|
||||
{
|
||||
var citizenProvince = await _contextMetadata.Provinces.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(updated.CitizenProvinceId));
|
||||
|
||||
if (citizenProvince == null)
|
||||
throw new Exception(GlobalMessages.ProvinceNotFound);
|
||||
|
||||
candidate.CitizenProvinceId = citizenProvince.Id;
|
||||
candidate.CitizenProvinceName = citizenProvince.Name;
|
||||
}
|
||||
|
||||
if (updated.CitizenDistrictId != null)
|
||||
{
|
||||
var citizenDistrict = await _contextMetadata.Districts.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(updated.CitizenDistrictId));
|
||||
|
||||
if (citizenDistrict == null)
|
||||
throw new Exception(GlobalMessages.DistrictNotFound);
|
||||
|
||||
candidate.CitizenDistrictId = citizenDistrict.Id;
|
||||
candidate.CitizenDistrictName = citizenDistrict.Name;
|
||||
}
|
||||
|
||||
if (updated.RegistProvinceId != null)
|
||||
{
|
||||
var registProvince = await _contextMetadata.Provinces.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(updated.RegistProvinceId));
|
||||
|
||||
if (registProvince == null)
|
||||
throw new Exception(GlobalMessages.ProvinceNotFound);
|
||||
|
||||
candidate.RegistProvinceId = registProvince.Id;
|
||||
candidate.RegistProvinceName = registProvince.Name;
|
||||
}
|
||||
|
||||
if (updated.RegistDistrictId != null)
|
||||
{
|
||||
var registDistrict = await _contextMetadata.Districts.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(updated.RegistDistrictId));
|
||||
|
||||
if (registDistrict == null)
|
||||
throw new Exception(GlobalMessages.DistrictNotFound);
|
||||
|
||||
candidate.RegistDistrictId = registDistrict.Id;
|
||||
candidate.RegistDistrictName = registDistrict.Name;
|
||||
}
|
||||
|
||||
if (updated.RegistSubDistrictId != null)
|
||||
{
|
||||
var registSubDistrict = await _contextMetadata.SubDistricts.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(updated.RegistSubDistrictId));
|
||||
|
||||
if (registSubDistrict == null)
|
||||
throw new Exception(GlobalMessages.SubDistrictNotFound);
|
||||
|
||||
candidate.RegistSubDistrictId = registSubDistrict.Id;
|
||||
candidate.RegistSubDistrictName = registSubDistrict.Name;
|
||||
candidate.RegistZipCode = registSubDistrict.ZipCode;
|
||||
}
|
||||
|
||||
if (updated.CurrentProvinceId != null)
|
||||
{
|
||||
var currentProvince = await _contextMetadata.Provinces.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(updated.CurrentProvinceId));
|
||||
|
||||
if (currentProvince == null)
|
||||
throw new Exception(GlobalMessages.ProvinceNotFound);
|
||||
|
||||
candidate.CurrentProvinceId = currentProvince.Id;
|
||||
candidate.CurrentProvinceName = currentProvince.Name;
|
||||
}
|
||||
|
||||
if (updated.CurrentDistrictId != null)
|
||||
{
|
||||
var currentDistrict = await _contextMetadata.Districts.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(updated.CurrentDistrictId));
|
||||
|
||||
if (currentDistrict == null)
|
||||
throw new Exception(GlobalMessages.DistrictNotFound);
|
||||
|
||||
candidate.CurrentDistrictId = currentDistrict.Id;
|
||||
candidate.CurrentDistrictName = currentDistrict.Name;
|
||||
}
|
||||
|
||||
if (updated.CurrentSubDistrictId != null)
|
||||
{
|
||||
var currentSubDistrict = await _contextMetadata.SubDistricts.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(updated.CurrentSubDistrictId));
|
||||
|
||||
if (currentSubDistrict == null)
|
||||
throw new Exception(GlobalMessages.SubDistrictNotFound);
|
||||
|
||||
candidate.CurrentSubDistrictId = currentSubDistrict.Id;
|
||||
candidate.CurrentSubDistrictName = currentSubDistrict.Name;
|
||||
candidate.CurrentZipCode = currentSubDistrict.ZipCode;
|
||||
}
|
||||
|
||||
if (updated.MarryPrefixId != null)
|
||||
{
|
||||
var prefix = await _contextMetadata.Prefixes.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(updated.MarryPrefixId));
|
||||
|
||||
if (prefix == null)
|
||||
throw new Exception(GlobalMessages.PrefixNotFound);
|
||||
|
||||
candidate.MarryPrefixId = prefix.Id;
|
||||
candidate.MarryPrefixName = prefix.Name;
|
||||
}
|
||||
|
||||
if (updated.FatherPrefixId != null)
|
||||
{
|
||||
var prefix = await _contextMetadata.Prefixes.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(updated.FatherPrefixId));
|
||||
|
||||
if (prefix == null)
|
||||
throw new Exception(GlobalMessages.PrefixNotFound);
|
||||
|
||||
candidate.FatherPrefixId = prefix.Id;
|
||||
candidate.FatherPrefixName = prefix.Name;
|
||||
}
|
||||
|
||||
if (updated.MotherPrefixId != null)
|
||||
{
|
||||
var prefix = await _contextMetadata.Prefixes.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(updated.MotherPrefixId));
|
||||
|
||||
if (prefix == null)
|
||||
throw new Exception(GlobalMessages.PrefixNotFound);
|
||||
|
||||
candidate.MotherPrefixId = prefix.Id;
|
||||
candidate.MotherPrefixName = prefix.Name;
|
||||
}
|
||||
|
||||
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, string positionId, CandidateInformationResponseItem updated)
|
||||
{
|
||||
var candidateId = await CreateAsyncCandidate(examId, positionId);
|
||||
|
|
@ -912,6 +1164,29 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task UpdateAsyncAdminProfileImage(string candidateId, IFormFile file)
|
||||
{
|
||||
var candidate = await _context.Candidates.AsQueryable()
|
||||
.Include(x => x.ProfileImg)
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(candidateId));
|
||||
|
||||
if (candidate == null)
|
||||
throw new Exception(GlobalMessages.ExamNotFound);
|
||||
|
||||
if (candidate.ProfileImg != null)
|
||||
{
|
||||
await DeleteDocument(candidate.ProfileImg.Id.ToString());
|
||||
}
|
||||
|
||||
var doc = await _minioService.UploadFileAsync(file);
|
||||
|
||||
var document = await _context.Documents.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == doc.Id);
|
||||
|
||||
candidate.ProfileImg = document;
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task UpdateAsyncAddress(string examId, string positionId, CandidateAddressResponseItem updated)
|
||||
{
|
||||
var candidateId = await CreateAsyncCandidate(examId, positionId);
|
||||
|
|
@ -1114,6 +1389,32 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task UpdateAsyncAdminDocument(string candidateId, IFormFile file)
|
||||
{
|
||||
var candidate = await _context.Candidates.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(candidateId));
|
||||
|
||||
if (candidate == null)
|
||||
throw new Exception(GlobalMessages.ExamNotFound);
|
||||
|
||||
var doc = await _minioService.UploadFileAsync(file);
|
||||
|
||||
var document = await _context.Documents.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == doc.Id);
|
||||
|
||||
if (document == null)
|
||||
throw new Exception(GlobalMessages.NoFileToUpload);
|
||||
|
||||
var candidateDocument = new CandidateDocument
|
||||
{
|
||||
Candidate = candidate,
|
||||
Document = document,
|
||||
};
|
||||
|
||||
await _context.CandidateDocuments.AddAsync(candidateDocument);
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task DeleteDocument(string documentId)
|
||||
{
|
||||
await _minioService.DeleteFileAsync(Guid.Parse(documentId));
|
||||
|
|
@ -1136,6 +1437,17 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
await _minioService.DeleteFileAsync(Guid.Parse(documentId));
|
||||
}
|
||||
|
||||
public async Task DeleteAsyncAdminDocument(string candidateId, string documentId)
|
||||
{
|
||||
var candidate = await _context.Candidates.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(candidateId));
|
||||
|
||||
if (candidate == null)
|
||||
throw new Exception(GlobalMessages.ExamNotFound);
|
||||
|
||||
await _minioService.DeleteFileAsync(Guid.Parse(documentId));
|
||||
}
|
||||
|
||||
public async Task CreateAsyncCareer(string examId, string positionId, CandidateCareerResponseItem updated)
|
||||
{
|
||||
var candidateId = await CreateAsyncCandidate(examId, positionId);
|
||||
|
|
@ -1164,6 +1476,32 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task CreateAsyncAdminCareer(string candidateId, CandidateCareerResponseItem updated)
|
||||
{
|
||||
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, string positionId, CandidateEducationResponseItem updated)
|
||||
{
|
||||
var candidateId = await CreateAsyncCandidate(examId, positionId);
|
||||
|
|
@ -1199,6 +1537,39 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task CreateAsyncAdminEducation(string candidateId, CandidateEducationResponseItem updated)
|
||||
{
|
||||
var candidate = await _context.Candidates.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(candidateId));
|
||||
|
||||
var educationLevel = await _contextMetadata.EducationLevels.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(updated.EducationLevelId));
|
||||
|
||||
if (educationLevel == null)
|
||||
throw new Exception(GlobalMessages.EducationLevelNotFound);
|
||||
|
||||
var education = new Education
|
||||
{
|
||||
Candidate = candidate,
|
||||
EducationLevelId = educationLevel.Id,
|
||||
EducationLevelName = educationLevel.Name,
|
||||
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()
|
||||
|
|
@ -1475,6 +1846,35 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
};
|
||||
}
|
||||
|
||||
public async Task<RequestCardCandidate> GetsAsyncAdminCardCandidate(string candidateId)
|
||||
{
|
||||
var candidate = await _context.Candidates.AsQueryable()
|
||||
.Include(x => x.ProfileImg)
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(candidateId));
|
||||
|
||||
if (candidate == null)
|
||||
throw new Exception(GlobalMessages.CandidateNotFound);
|
||||
|
||||
return new RequestCardCandidate
|
||||
{
|
||||
Avatar = candidate.ProfileImg == null ? "" : _minioService.ImagesPath(candidate.ProfileImg.Id).Result,
|
||||
FirstName = candidate.FirstName,
|
||||
LastName = candidate.LastName,
|
||||
Prefix = candidate.PrefixName,
|
||||
CitizenId = candidate.CitizenId,
|
||||
ExamIdenNumber = candidate.ExamIdenNumber,
|
||||
SeatNumber = candidate.SeatNumber,
|
||||
PointTotalB = candidate.PointTotalB,
|
||||
PointB = candidate.PointB,
|
||||
ResultB = candidate.ResultB,
|
||||
PointTotalC = candidate.PointTotalC,
|
||||
PointC = candidate.PointC,
|
||||
ResultC = candidate.ResultC,
|
||||
Pass = candidate.Pass,
|
||||
Id = candidate.Id,
|
||||
};
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue