2023-03-17 14:24:43 +07:00
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
using BMA.EHR.Recruit.Service.Data;
|
|
|
|
|
using BMA.EHR.Recruit.Service.Models.Recruits;
|
2023-05-02 22:59:01 +07:00
|
|
|
using BMA.EHR.Recruit.Service.Core;
|
2023-07-26 18:42:42 +07:00
|
|
|
using BMA.EHR.MetaData.Service.Models;
|
|
|
|
|
using BMA.EHR.Domain.Models.Placement;
|
|
|
|
|
using BMA.EHR.Recurit.Service.Data;
|
|
|
|
|
using System.Security.Claims;
|
2024-07-03 00:42:41 +07:00
|
|
|
using System.Net.Http.Headers;
|
|
|
|
|
using Newtonsoft.Json;
|
2023-03-17 14:24:43 +07:00
|
|
|
|
|
|
|
|
namespace BMA.EHR.Recruit.Service.Services
|
|
|
|
|
{
|
2023-07-26 18:42:42 +07:00
|
|
|
public class RecruitService
|
|
|
|
|
{
|
|
|
|
|
private readonly ApplicationDbContext _context;
|
|
|
|
|
private readonly MetadataDbContext _contextMetadata;
|
2025-01-05 21:59:00 +07:00
|
|
|
private readonly OrgDbContext _contextOrg;
|
2023-07-26 18:42:42 +07:00
|
|
|
private readonly MinIOService _minIOService;
|
|
|
|
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
2024-07-03 00:42:41 +07:00
|
|
|
private readonly IConfiguration _configuration;
|
2023-05-02 22:59:01 +07:00
|
|
|
|
2023-07-26 18:42:42 +07:00
|
|
|
public RecruitService(ApplicationDbContext context,
|
2025-01-05 21:59:00 +07:00
|
|
|
MetadataDbContext contextMetadata,
|
|
|
|
|
OrgDbContext contextOrg,
|
|
|
|
|
IHttpContextAccessor httpContextAccessor,
|
|
|
|
|
MinIOService minIOService,
|
|
|
|
|
IConfiguration configuration)
|
2023-07-26 18:42:42 +07:00
|
|
|
{
|
|
|
|
|
_context = context;
|
|
|
|
|
_contextMetadata = contextMetadata;
|
2025-01-05 21:59:00 +07:00
|
|
|
_contextOrg = contextOrg;
|
2023-07-26 18:42:42 +07:00
|
|
|
_minIOService = minIOService;
|
|
|
|
|
_httpContextAccessor = httpContextAccessor;
|
2024-07-03 00:42:41 +07:00
|
|
|
_configuration = configuration;
|
2023-07-26 18:42:42 +07:00
|
|
|
}
|
2023-05-02 22:59:01 +07:00
|
|
|
|
2023-07-26 18:42:42 +07:00
|
|
|
#region " Properties "
|
|
|
|
|
|
|
|
|
|
private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
|
|
|
|
|
|
|
|
|
|
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
|
2024-07-03 00:42:41 +07:00
|
|
|
private string? token => _httpContextAccessor?.HttpContext?.Request.Headers["Authorization"];
|
2023-07-26 18:42:42 +07:00
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
public int GetExamCount(string citizenId)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var count = _context.Recruits.AsQueryable()
|
|
|
|
|
.Where(x => x.CitizenId == citizenId)
|
|
|
|
|
.Count();
|
|
|
|
|
|
|
|
|
|
return count;
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<string> GetExamAttributeAsync(Guid period, Guid exam)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var payment = await _context.RecruitPayments.AsQueryable()
|
|
|
|
|
.Include(x => x.Recruit)
|
|
|
|
|
.ThenInclude(x => x.RecruitImport)
|
|
|
|
|
.Where(x => x.Recruit.Id == exam)
|
|
|
|
|
.Where(x => x.Recruit.RecruitImport.Id == period)
|
|
|
|
|
.FirstOrDefaultAsync();
|
|
|
|
|
|
|
|
|
|
return payment != null ? "มีคุณสมบัติ" : "ไม่มีคุณสมบัติ";
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool CheckValidCertificate(DateTime certDate, int nextYear = 5)
|
|
|
|
|
{
|
|
|
|
|
var valid = true;
|
|
|
|
|
if (DateTime.Now.Date > certDate.Date.AddYears(nextYear))
|
|
|
|
|
valid = false;
|
|
|
|
|
|
|
|
|
|
return valid;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task UpdateDocAsync(Guid ImportId, IFormFileCollection files)
|
|
|
|
|
{
|
|
|
|
|
var periodExam = await _context.RecruitImports.AsQueryable()
|
|
|
|
|
.FirstOrDefaultAsync(x => x.Id == ImportId);
|
|
|
|
|
|
|
|
|
|
if (periodExam == null)
|
|
|
|
|
throw new Exception(GlobalMessages.DataNotFound);
|
|
|
|
|
|
|
|
|
|
foreach (var file in files)
|
|
|
|
|
{
|
|
|
|
|
var doc = await _minIOService.UploadFileAsync(file);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var periodExamDocument = new RecruitImportDocument
|
|
|
|
|
{
|
|
|
|
|
RecruitImportId = ImportId,
|
|
|
|
|
DocumentId = doc.Id,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
await _context.RecruitImportDocuments.AddAsync(periodExamDocument);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await _context.SaveChangesAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task UpdateImageAsync(Guid ImportId, IFormFileCollection files)
|
|
|
|
|
{
|
|
|
|
|
var periodExam = await _context.RecruitImports.AsQueryable()
|
|
|
|
|
.FirstOrDefaultAsync(x => x.Id == ImportId);
|
|
|
|
|
|
|
|
|
|
if (periodExam == null)
|
|
|
|
|
throw new Exception(GlobalMessages.DataNotFound);
|
|
|
|
|
|
|
|
|
|
foreach (var file in files)
|
|
|
|
|
{
|
|
|
|
|
var doc = await _minIOService.UploadFileAsync(file);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var periodExamImage = new RecruitImportImage
|
|
|
|
|
{
|
|
|
|
|
RecruitImportId = ImportId,
|
|
|
|
|
DocumentId = doc.Id,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
await _context.RecruitImportImages.AddAsync(periodExamImage);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await _context.SaveChangesAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task DeleteImageAsync(Guid id)
|
|
|
|
|
{
|
|
|
|
|
var image = await _context.RecruitImportImages.AsQueryable()
|
|
|
|
|
.Include(x => x.Document)
|
|
|
|
|
.FirstOrDefaultAsync(x => x.Id == id);
|
|
|
|
|
if (image == null)
|
|
|
|
|
throw new Exception(GlobalMessages.DataNotFound);
|
|
|
|
|
|
|
|
|
|
var doc_id = image.Document.Id;
|
|
|
|
|
_context.RecruitImportImages.Remove(image);
|
|
|
|
|
await _context.SaveChangesAsync();
|
|
|
|
|
|
|
|
|
|
await _minIOService.DeleteFileAsync(doc_id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task DeleteDocAsync(Guid id)
|
|
|
|
|
{
|
|
|
|
|
var doc = await _context.RecruitImportDocuments.AsQueryable()
|
|
|
|
|
.Include(x => x.Document)
|
|
|
|
|
.FirstOrDefaultAsync(x => x.Id == id);
|
|
|
|
|
if (doc == null)
|
|
|
|
|
throw new Exception(GlobalMessages.DataNotFound);
|
|
|
|
|
|
|
|
|
|
var doc_id = doc.Document.Id;
|
|
|
|
|
_context.RecruitImportDocuments.Remove(doc);
|
|
|
|
|
await _context.SaveChangesAsync();
|
|
|
|
|
|
|
|
|
|
await _minIOService.DeleteFileAsync(doc_id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task UpdateAsyncRecruitToPlacement(Guid examId)
|
|
|
|
|
{
|
2025-01-05 21:59:00 +07:00
|
|
|
try
|
2023-07-26 18:42:42 +07:00
|
|
|
{
|
2025-01-05 21:59:00 +07:00
|
|
|
var recruitImport = await _context.RecruitImports.AsQueryable()
|
|
|
|
|
.FirstOrDefaultAsync(x => x.Id == examId);
|
2024-07-03 00:42:41 +07:00
|
|
|
|
2025-01-05 21:59:00 +07:00
|
|
|
if (recruitImport == null)
|
|
|
|
|
throw new Exception(GlobalMessages.DataNotFound);
|
2024-07-03 00:42:41 +07:00
|
|
|
|
2025-01-05 21:59:00 +07:00
|
|
|
var _placement = await _contextMetadata.Placements.AsQueryable()
|
|
|
|
|
.FirstOrDefaultAsync(x => x.PlacementType.Name == "สอบแข่งขัน" && x.RefId == recruitImport.Id);
|
|
|
|
|
if (_placement != null)
|
|
|
|
|
throw new Exception("รอบการสอบนี้ได้ทำการบรรจุไปแล้ว");
|
2023-07-26 18:42:42 +07:00
|
|
|
|
2025-01-05 21:59:00 +07:00
|
|
|
var placement = new Placement
|
2023-07-26 18:42:42 +07:00
|
|
|
{
|
2025-01-05 21:59:00 +07:00
|
|
|
Name = recruitImport.Name,
|
|
|
|
|
RefId = recruitImport.Id,
|
|
|
|
|
Round = recruitImport.Order == null ? "" : recruitImport.Order.ToString(),
|
|
|
|
|
Year = (int)(recruitImport.Year == null ? 0 : recruitImport.Year),
|
|
|
|
|
Number = await _context.Recruits.AsQueryable().Where(x => x.RecruitImport == recruitImport).CountAsync(),
|
|
|
|
|
PlacementType = await _contextMetadata.PlacementTypes.FirstOrDefaultAsync(x => x.Name.Trim().ToUpper().Contains("สอบแข่งขัน")) == null ? await _contextMetadata.PlacementTypes.FirstOrDefaultAsync() : await _contextMetadata.PlacementTypes.FirstOrDefaultAsync(x => x.Name.Trim().ToUpper().Contains("สอบแข่งขัน")),
|
|
|
|
|
StartDate = DateTime.Now,
|
|
|
|
|
EndDate = DateTime.Now.AddYears(2).AddDays(-1),
|
2023-07-26 18:42:42 +07:00
|
|
|
CreatedAt = DateTime.Now,
|
|
|
|
|
CreatedUserId = UserId ?? "",
|
|
|
|
|
CreatedFullName = FullName ?? "",
|
|
|
|
|
LastUpdatedAt = DateTime.Now,
|
|
|
|
|
LastUpdateUserId = UserId ?? "",
|
|
|
|
|
LastUpdateFullName = FullName ?? "",
|
|
|
|
|
};
|
2025-01-05 21:59:00 +07:00
|
|
|
await _contextMetadata.Placements.AddAsync(placement);
|
|
|
|
|
var candidates = await _context.Recruits.AsQueryable()
|
|
|
|
|
.Include(x => x.Addresses)
|
|
|
|
|
.Include(x => x.Certificates)
|
|
|
|
|
.Include(x => x.Educations)
|
|
|
|
|
.Include(x => x.Occupations)
|
|
|
|
|
.Where(x => x.RecruitImport == recruitImport)
|
|
|
|
|
.ToListAsync();
|
|
|
|
|
foreach (var candidate in candidates)
|
|
|
|
|
{
|
|
|
|
|
var IsOfficer = false;
|
|
|
|
|
dynamic org = null;
|
|
|
|
|
var apiUrl = $"{_configuration["API"]}/org/profile/citizenid/position/{candidate.CitizenId}";
|
|
|
|
|
using (var client = new HttpClient())
|
|
|
|
|
{
|
|
|
|
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
|
|
|
|
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
|
|
|
|
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
|
|
|
|
|
var _res = await client.SendAsync(_req);
|
|
|
|
|
var _result = await _res.Content.ReadAsStringAsync();
|
|
|
|
|
|
|
|
|
|
org = JsonConvert.DeserializeObject<dynamic>(_result);
|
|
|
|
|
|
|
|
|
|
if (org == null || org.result == null)
|
|
|
|
|
{
|
|
|
|
|
IsOfficer = false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
IsOfficer = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
var Address = candidate.Addresses.FirstOrDefault() == null ? null : $"{candidate.Addresses.FirstOrDefault().Address}";
|
|
|
|
|
var Moo = candidate.Addresses.FirstOrDefault() == null ? null : $" หมู่ {candidate.Addresses.FirstOrDefault().Moo}";
|
|
|
|
|
var Soi = candidate.Addresses.FirstOrDefault() == null ? null : $" ซอย {candidate.Addresses.FirstOrDefault().Soi}";
|
|
|
|
|
var Road = candidate.Addresses.FirstOrDefault() == null ? null : $" ถนน {candidate.Addresses.FirstOrDefault().Road}";
|
|
|
|
|
var Address1 = candidate.Addresses.FirstOrDefault() == null ? null : $"{candidate.Addresses.FirstOrDefault().Address1}";
|
|
|
|
|
var Moo1 = candidate.Addresses.FirstOrDefault() == null ? null : $" หมู่ {candidate.Addresses.FirstOrDefault().Moo1}";
|
|
|
|
|
var Soi1 = candidate.Addresses.FirstOrDefault() == null ? null : $" ซอย {candidate.Addresses.FirstOrDefault().Soi1}";
|
|
|
|
|
var Road1 = candidate.Addresses.FirstOrDefault() == null ? null : $" ถนน {candidate.Addresses.FirstOrDefault().Road1}";
|
|
|
|
|
var scoreImport = await _context.ScoreImports.AsQueryable()
|
|
|
|
|
.FirstOrDefaultAsync(x => x.RecruitImport == recruitImport);
|
|
|
|
|
var recruitScore = await _context.RecruitScores.AsQueryable()
|
|
|
|
|
.Where(x => x.ScoreImport == scoreImport)
|
|
|
|
|
.Where(x => x.ExamId == candidate.ExamId)
|
|
|
|
|
.Where(x => x.ExamStatus == "ผ่าน")
|
|
|
|
|
.FirstOrDefaultAsync(x => x.ExamId == candidate.ExamId && x.ScoreImport == scoreImport);
|
|
|
|
|
if (recruitScore == null)
|
|
|
|
|
continue;
|
|
|
|
|
var placementProfile = new PlacementProfile
|
|
|
|
|
{
|
|
|
|
|
Placement = placement,
|
|
|
|
|
PositionCandidate = candidate.PositionName,
|
|
|
|
|
PositionType = candidate.PositionType,
|
|
|
|
|
PositionLevel = candidate.PositionLevel,
|
|
|
|
|
Prefix = candidate.Prefix,
|
|
|
|
|
Firstname = candidate.FirstName,
|
|
|
|
|
Lastname = candidate.LastName,
|
|
|
|
|
Gender = candidate.Gendor,
|
|
|
|
|
Nationality = candidate.National,
|
|
|
|
|
Race = candidate.Race,
|
|
|
|
|
Religion = candidate.Religion,
|
|
|
|
|
DateOfBirth = candidate.DateOfBirth,
|
|
|
|
|
Relationship = candidate.Marry,
|
|
|
|
|
CitizenId = candidate.CitizenId,
|
|
|
|
|
CitizenProvinceId = _contextOrg.province.FirstOrDefault(x => x.name == candidate.CitizenCardIssuer)?.Id ?? null,
|
|
|
|
|
CitizenDate = candidate.CitizenCardExpireDate,
|
|
|
|
|
Telephone = candidate?.Addresses?.FirstOrDefault()?.Telephone ?? null,
|
|
|
|
|
MobilePhone = candidate?.Addresses?.FirstOrDefault()?.Mobile ?? null,
|
|
|
|
|
RegistAddress = $"{Address}{Moo}{Soi}{Road}",
|
|
|
|
|
RegistProvinceId = _contextOrg.province.FirstOrDefault(x => x.name == (candidate!.Addresses!.FirstOrDefault()!.Province ?? ""))?.Id ?? null,
|
|
|
|
|
RegistDistrictId = _contextOrg.district.FirstOrDefault(x => x.name == (candidate!.Addresses!.FirstOrDefault()!.District ?? ""))?.Id ?? null,
|
|
|
|
|
RegistSubDistrictId = _contextOrg.subDistrict.FirstOrDefault(x => x.name == (candidate!.Addresses!.FirstOrDefault()!.Soi ?? ""))?.Id ?? null,
|
|
|
|
|
RegistZipCode = candidate?.Addresses?.FirstOrDefault()?.ZipCode ?? null,
|
|
|
|
|
RegistSame = false,
|
|
|
|
|
CurrentAddress = $"{Address1}{Moo1}{Soi1}{Road1}",
|
|
|
|
|
CurrentProvinceId = _contextOrg.province.FirstOrDefault(x => x.name == (candidate!.Addresses!.FirstOrDefault()!.Province1 ?? ""))?.Id ?? null,
|
|
|
|
|
CurrentDistrictId = _contextOrg.district.FirstOrDefault(x => x.name == (candidate!.Addresses!.FirstOrDefault()!.District1 ?? ""))?.Id ?? null,
|
|
|
|
|
CurrentSubDistrictId = _contextOrg.subDistrict.FirstOrDefault(x => x.name == (candidate!.Addresses!.FirstOrDefault()!.Soi1 ?? ""))?.Id ?? null,
|
|
|
|
|
CurrentZipCode = candidate?.Addresses?.FirstOrDefault()?.ZipCode1 ?? null,
|
|
|
|
|
Marry = candidate?.Marry?.Contains("สมรส") ?? false,
|
|
|
|
|
|
|
|
|
|
OccupationPositionType = "other",
|
|
|
|
|
OccupationTelephone = candidate?.Occupations?.FirstOrDefault()?.Telephone ?? null,
|
|
|
|
|
OccupationPosition = candidate?.Occupations?.FirstOrDefault()?.Position ?? null,
|
|
|
|
|
|
|
|
|
|
PointTotalA = recruitScore == null ? null : Convert.ToDouble(recruitScore.FullA),
|
|
|
|
|
PointA = recruitScore == null ? null : Convert.ToDouble(recruitScore.SumA),
|
|
|
|
|
PointTotalB = recruitScore == null ? null : Convert.ToDouble(recruitScore.FullB),
|
|
|
|
|
PointB = recruitScore == null ? null : Convert.ToDouble(recruitScore.SumB),
|
|
|
|
|
PointTotalC = recruitScore == null ? null : Convert.ToDouble(recruitScore.FullC),
|
|
|
|
|
PointC = recruitScore == null ? null : Convert.ToDouble(recruitScore.SumC),
|
|
|
|
|
ExamNumber = recruitScore == null || int.TryParse(recruitScore.Number, out int n) == false ? null : Convert.ToInt32(recruitScore.Number),
|
|
|
|
|
ExamRound = null,
|
|
|
|
|
IsRelief = false,
|
|
|
|
|
PlacementStatus = "UN-CONTAIN",
|
|
|
|
|
Pass = recruitScore == null ? null : recruitScore.ExamStatus,
|
|
|
|
|
RemarkHorizontal = "โดยมีเงื่อนไขว่าต้องปฏิบัติงานให้กรุงเทพมหานครเป็นระยะเวลาไม่น้อยกว่า ๕ ปี นับแต่วันที่ได้รับการบรรจุและแต่งตั้ง โดยห้ามโอนไปหน่วยงานหรือส่วนราชการอื่น เว้นเเต่ลาออกจากราชการ",
|
|
|
|
|
Amount = org?.result?.amount ?? null,
|
|
|
|
|
PositionSalaryAmount = org?.result?.positionSalaryAmount ?? null,
|
|
|
|
|
MouthSalaryAmount = org?.result?.mouthSalaryAmount ?? null,
|
|
|
|
|
CreatedAt = DateTime.Now,
|
|
|
|
|
CreatedUserId = UserId ?? "",
|
|
|
|
|
CreatedFullName = FullName ?? "",
|
|
|
|
|
LastUpdatedAt = DateTime.Now,
|
|
|
|
|
LastUpdateUserId = UserId ?? "",
|
|
|
|
|
LastUpdateFullName = FullName ?? "",
|
|
|
|
|
IsOfficer = IsOfficer,
|
|
|
|
|
profileId = org?.result?.profileId ?? null,
|
|
|
|
|
IsOld = org == null || org.result == null ? false : true,
|
|
|
|
|
AmountOld = org?.result?.AmountOld ?? null,
|
|
|
|
|
nodeOld = org?.result?.node ?? null,
|
|
|
|
|
nodeIdOld = org?.result?.nodeId ?? null,
|
|
|
|
|
posmasterIdOld = org?.result?.posmasterId ?? null,
|
|
|
|
|
rootOld = org?.result?.root ?? null,
|
|
|
|
|
rootIdOld = org?.result?.rootId ?? null,
|
|
|
|
|
rootShortNameOld = org?.result?.rootShortName ?? null,
|
|
|
|
|
child1Old = org?.result?.child1 ?? null,
|
|
|
|
|
child1IdOld = org?.result?.child1Id ?? null,
|
|
|
|
|
child1ShortNameOld = org?.result?.child1ShortName ?? null,
|
|
|
|
|
child2Old = org?.result?.child2 ?? null,
|
|
|
|
|
child2IdOld = org?.result?.child2Id ?? null,
|
|
|
|
|
child2ShortNameOld = org?.result?.child2ShortName ?? null,
|
|
|
|
|
child3Old = org?.result?.child3 ?? null,
|
|
|
|
|
child3IdOld = org?.result?.child3Id ?? null,
|
|
|
|
|
child3ShortNameOld = org?.result?.child3ShortName ?? null,
|
|
|
|
|
child4Old = org?.result?.child4 ?? null,
|
|
|
|
|
child4IdOld = org?.result?.child4Id ?? null,
|
|
|
|
|
child4ShortNameOld = org?.result?.child4ShortName ?? null,
|
|
|
|
|
orgRevisionIdOld = org?.result?.orgRevisionId ?? null,
|
|
|
|
|
posMasterNoOld = org?.result?.posMasterNo ?? null,
|
|
|
|
|
positionNameOld = org?.result?.position ?? null,
|
|
|
|
|
posTypeIdOld = org?.result?.posTypeId ?? null,
|
|
|
|
|
posTypeNameOld = org?.result?.posTypeName ?? null,
|
|
|
|
|
posLevelIdOld = org?.result?.posLevelId ?? null,
|
|
|
|
|
posLevelNameOld = org?.result?.posLevelName ?? null,
|
|
|
|
|
};
|
|
|
|
|
await _contextMetadata.PlacementProfiles.AddAsync(placementProfile);
|
|
|
|
|
|
|
|
|
|
var placementEducation = new PlacementEducation
|
|
|
|
|
{
|
|
|
|
|
PlacementProfile = placementProfile,
|
|
|
|
|
EducationLevelId = _contextOrg.educationLevel.FirstOrDefault(x => x.name == (candidate!.Educations!.FirstOrDefault()!.HighDegree ?? ""))?.Id ?? null,
|
|
|
|
|
EducationLevelName = _contextOrg.educationLevel.FirstOrDefault(x => x.name == (candidate!.Educations!.FirstOrDefault()!.HighDegree ?? ""))?.name ?? null,
|
|
|
|
|
Field = candidate?.Educations?.FirstOrDefault()?.Major ?? null,
|
|
|
|
|
Gpa = candidate?.Educations?.FirstOrDefault()?.GPA!.ToString() ?? null,
|
|
|
|
|
Institute = candidate?.Educations?.FirstOrDefault()?.University ?? null,
|
|
|
|
|
Degree = candidate?.Educations?.FirstOrDefault()?.Degree ?? null,
|
|
|
|
|
FinishDate = candidate?.Educations?.FirstOrDefault()?.BachelorDate ?? null,
|
|
|
|
|
IsDate = true,
|
|
|
|
|
CreatedAt = DateTime.Now,
|
|
|
|
|
CreatedUserId = UserId ?? "",
|
|
|
|
|
LastUpdatedAt = DateTime.Now,
|
|
|
|
|
LastUpdateUserId = UserId ?? "",
|
|
|
|
|
CreatedFullName = FullName ?? "",
|
|
|
|
|
LastUpdateFullName = FullName ?? "",
|
|
|
|
|
};
|
|
|
|
|
await _contextMetadata.PlacementEducations.AddAsync(placementEducation);
|
|
|
|
|
|
|
|
|
|
var placementCertificate = new PlacementCertificate
|
|
|
|
|
{
|
|
|
|
|
PlacementProfile = placementProfile,
|
|
|
|
|
CertificateNo = candidate?.Certificates?.FirstOrDefault()?.CertificateNo ?? null,
|
|
|
|
|
IssueDate = candidate?.Certificates?.FirstOrDefault()?.IssueDate ?? null,
|
|
|
|
|
ExpireDate = candidate?.Certificates?.FirstOrDefault()?.ExpiredDate ?? null,
|
|
|
|
|
CertificateType = candidate?.Certificates?.FirstOrDefault()?.Description ?? null,
|
|
|
|
|
CreatedAt = DateTime.Now,
|
|
|
|
|
CreatedUserId = UserId ?? "",
|
|
|
|
|
LastUpdatedAt = DateTime.Now,
|
|
|
|
|
LastUpdateUserId = UserId ?? "",
|
|
|
|
|
CreatedFullName = FullName ?? "",
|
|
|
|
|
LastUpdateFullName = FullName ?? "",
|
|
|
|
|
};
|
|
|
|
|
await _contextMetadata.PlacementCertificates.AddAsync(placementCertificate);
|
|
|
|
|
await _contextMetadata.SaveChangesAsync();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
throw;
|
2023-07-26 18:42:42 +07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2023-03-17 14:24:43 +07:00
|
|
|
}
|