diff --git a/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs b/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs
index 9d554060..ded7ecba 100644
--- a/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs
+++ b/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs
@@ -2557,7 +2557,7 @@ namespace BMA.EHR.Application.Repositories.Commands
{
case "C-PM-01":
case "C-PM-02":
- await ExecuteCommand01_02Async(command);
+ await ExecuteCommand01_02Async(command, token);
break;
case "C-PM-03":
await ExecuteCommand03Async(command);
@@ -2675,7 +2675,7 @@ namespace BMA.EHR.Application.Repositories.Commands
///
/// object ของรายการคำสั่ง
///
- private async Task ExecuteCommand01_02Async(Command command)
+ private async Task ExecuteCommand01_02Async(Command command, string token="")
{
try
{
@@ -2756,228 +2756,363 @@ namespace BMA.EHR.Application.Repositories.Commands
throw new Exception("Invalid placement profile: " + recv.RefPlacementProfileId);
// ใส่ฟีลจากข้อมูล
- var profile = new Profile
+ ////var profile = new Profile
+ ////{
+ //// ProfileType = "officer",
+ //// CitizenId = placementProfile.CitizenId,
+ //// Prefix = placementProfile.Prefix,
+ //// FirstName = placementProfile.Firstname,
+ //// LastName = placementProfile.Lastname,
+ //// Gender = placementProfile.Gender,
+ //// Nationality = placementProfile.Nationality,
+ //// BirthDate = placementProfile.DateOfBirth == null ? DateTime.MinValue : placementProfile.DateOfBirth.Value,
+ //// RelationshipId = placementProfile.Relationship == null ? Guid.Empty : placementProfile.Relationship!.Id,
+ //// TelephoneNumber = placementProfile.Telephone,
+ //// Race = placementProfile.Race,
+ //// ReligionId = placementProfile.Religion == null ? Guid.Empty : placementProfile.Religion.Id,
+ //// BloodGroupId = placementProfile.BloodGroup == null ? Guid.Empty : placementProfile.BloodGroup.Id,
+
+ //// DateAppoint = placementProfile.RecruitDate == null ? null : placementProfile.RecruitDate.Value,
+ //// DateStart = placementProfile.RecruitDate == null ? null : placementProfile.RecruitDate.Value,
+
+ //// RegistrationAddress = placementProfile.RegistAddress,
+ //// RegistrationSubDistrictId = placementProfile.RegistSubDistrict == null ? Guid.Empty : placementProfile.RegistSubDistrict!.Id,
+ //// RegistrationDistrictId = placementProfile.RegistDistrict == null ? Guid.Empty : placementProfile.RegistDistrict!.Id,
+ //// RegistrationProvinceId = placementProfile.RegistProvince == null ? Guid.Empty : placementProfile.RegistProvince!.Id,
+ //// RegistrationZipCode = placementProfile.RegistSubDistrict == null ? null : placementProfile.RegistSubDistrict!.ZipCode,
+
+ //// CurrentAddress = placementProfile.CurrentAddress,
+ //// CurrentSubDistrictId = placementProfile.CurrentSubDistrict == null ? Guid.Empty : placementProfile.CurrentSubDistrict!.Id,
+ //// CurrentDistrictId = placementProfile.CurrentDistrict == null ? Guid.Empty : placementProfile.CurrentDistrict!.Id,
+ //// CurrentProvinceId = placementProfile.CurrentProvince == null ? Guid.Empty : placementProfile.CurrentProvince!.Id,
+ //// CurrentZipCode = placementProfile.CurrentSubDistrict == null ? null : placementProfile.CurrentSubDistrict!.ZipCode,
+
+ //// FatherPrefixId = placementProfile.FatherPrefix == null ? null : placementProfile.FatherPrefix.Id,
+ //// FatherFirstName = placementProfile.FatherFirstName,
+ //// FatherLastName = placementProfile.FatherLastName,
+ //// FatherCareer = placementProfile.FatherOccupation,
+ //// FatherLive = true,
+
+ //// MotherPrefixId = placementProfile.MotherPrefix == null ? null : placementProfile.MotherPrefix.Id,
+ //// MotherFirstName = placementProfile.MotherFirstName,
+ //// MotherLastName = placementProfile.MotherLastName,
+ //// MotherCareer = placementProfile.MotherOccupation,
+ //// MotherLive = true,
+
+ //// Couple = placementProfile.MarryPrefix == null ? false : true,
+ //// CouplePrefixId = placementProfile.MarryPrefix == null ? null : placementProfile.MarryPrefix.Id,
+ //// CoupleFirstName = placementProfile.MarryFirstName,
+ //// CoupleLastName = placementProfile.MarryLastName,
+ //// CoupleCareer = placementProfile.MarryOccupation,
+ //// CoupleLive = placementProfile.MarryPrefix == null ? false : true,
+
+ //// Position = placementProfile.PositionPath,
+ //// PositionPathSideId = placementProfile.PositionPathSide == null ? Guid.Empty : placementProfile.PositionPathSide.Id,
+ //// PositionType = placementProfile.PositionType,
+ //// PositionLevel = placementProfile.PositionLevel,
+ //// //PositionEmployeeLevel = placementProfile.PositionLevel,
+ //// PositionLineId = placementProfile.PositionLine == null ? Guid.Empty : placementProfile.PositionLine.Id,
+ //// PositionLine = placementProfile.PositionLine == null ? "" : placementProfile.PositionLine.Name,
+ //// PosNo = placementProfile.OrganizationPosition!.PositionNumber,
+
+ //// IsVerified = true,
+ //// IsProbation = true,
+ //// Physical = "",
+ //// Ability = "",
+ //// AvatarRef = "",
+ //// GovAgeAbsent = 0,
+ //// GovAgePlus = 0,
+ //// EntryStatus = "",
+ //// IsTransfer = false,
+ //// IsActive = true,
+ //// IsLeave = false,
+ //// VerifiedUser = "",
+ //// FirstNameOld = "",
+ //// LastNameOld = "",
+ //// // CoupleLive = false,
+ //// // FatherLive = false,
+ //// // MotherLive = false,
+ //// CreatedUser = "",
+
+ //// Educations = new List(),
+ //// Certificates = new List(),
+ //// Salaries = new List(),
+ //// CreatedAt = DateTime.Now,
+ //// CreatedFullName = FullName ?? "System Administrator",
+ //// CreatedUserId = UserId ?? "",
+ //// LastUpdatedAt = DateTime.Now,
+ //// LastUpdateFullName = FullName ?? "System Administrator",
+ //// LastUpdateUserId = UserId ?? "",
+
+ //// // organization
+ //// OrganizationShortNameId = placementProfile.OrganizationPosition!.Organization!.OrganizationShortName!.Id,
+ //// OrganizationShortName = placementProfile.OrganizationPosition!.Organization!.OrganizationShortName!.Name,
+ //// OrganizationOrganizationId = placementProfile.OrganizationPosition!.Organization!.OrganizationOrganization!.Id,
+ //// OrganizationOrganization = placementProfile.OrganizationPosition!.Organization!.OrganizationOrganization!.Name,
+ //// OcId = placementProfile.OrganizationPosition!.Organization!.Id,
+ //// Oc = _organizationCommonRepository.GetOrganizationNameFullPath(placementProfile.OrganizationPosition!.Organization!.Id, false, false, "/"),
+
+ ////};
+
+ /*ข้อมูล Profile ใหม่*/
+ var apiUrl = $"{_configuration["API"]}/org/profile/all";
+ var profileId = string.Empty;
+ using (var client = new HttpClient())
{
- ProfileType = "officer",
- CitizenId = placementProfile.CitizenId,
- Prefix = placementProfile.Prefix,
- FirstName = placementProfile.Firstname,
- LastName = placementProfile.Lastname,
- Gender = placementProfile.Gender,
- Nationality = placementProfile.Nationality,
- BirthDate = placementProfile.DateOfBirth == null ? DateTime.MinValue : placementProfile.DateOfBirth.Value,
- RelationshipId = placementProfile.Relationship == null ? Guid.Empty : placementProfile.Relationship!.Id,
- TelephoneNumber = placementProfile.Telephone,
- Race = placementProfile.Race,
- ReligionId = placementProfile.Religion == null ? Guid.Empty : placementProfile.Religion.Id,
- BloodGroupId = placementProfile.BloodGroup == null ? Guid.Empty : placementProfile.BloodGroup.Id,
-
- DateAppoint = placementProfile.RecruitDate == null ? null : placementProfile.RecruitDate.Value,
- DateStart = placementProfile.RecruitDate == null ? null : placementProfile.RecruitDate.Value,
-
- RegistrationAddress = placementProfile.RegistAddress,
- RegistrationSubDistrictId = placementProfile.RegistSubDistrict == null ? Guid.Empty : placementProfile.RegistSubDistrict!.Id,
- RegistrationDistrictId = placementProfile.RegistDistrict == null ? Guid.Empty : placementProfile.RegistDistrict!.Id,
- RegistrationProvinceId = placementProfile.RegistProvince == null ? Guid.Empty : placementProfile.RegistProvince!.Id,
- RegistrationZipCode = placementProfile.RegistSubDistrict == null ? null : placementProfile.RegistSubDistrict!.ZipCode,
-
- CurrentAddress = placementProfile.CurrentAddress,
- CurrentSubDistrictId = placementProfile.CurrentSubDistrict == null ? Guid.Empty : placementProfile.CurrentSubDistrict!.Id,
- CurrentDistrictId = placementProfile.CurrentDistrict == null ? Guid.Empty : placementProfile.CurrentDistrict!.Id,
- CurrentProvinceId = placementProfile.CurrentProvince == null ? Guid.Empty : placementProfile.CurrentProvince!.Id,
- CurrentZipCode = placementProfile.CurrentSubDistrict == null ? null : placementProfile.CurrentSubDistrict!.ZipCode,
-
- FatherPrefixId = placementProfile.FatherPrefix == null ? null : placementProfile.FatherPrefix.Id,
- FatherFirstName = placementProfile.FatherFirstName,
- FatherLastName = placementProfile.FatherLastName,
- FatherCareer = placementProfile.FatherOccupation,
- FatherLive = true,
-
- MotherPrefixId = placementProfile.MotherPrefix == null ? null : placementProfile.MotherPrefix.Id,
- MotherFirstName = placementProfile.MotherFirstName,
- MotherLastName = placementProfile.MotherLastName,
- MotherCareer = placementProfile.MotherOccupation,
- MotherLive = true,
-
- Couple = placementProfile.MarryPrefix == null ? false : true,
- CouplePrefixId = placementProfile.MarryPrefix == null ? null : placementProfile.MarryPrefix.Id,
- CoupleFirstName = placementProfile.MarryFirstName,
- CoupleLastName = placementProfile.MarryLastName,
- CoupleCareer = placementProfile.MarryOccupation,
- CoupleLive = placementProfile.MarryPrefix == null ? false : true,
-
- Position = placementProfile.PositionPath,
- PositionPathSideId = placementProfile.PositionPathSide == null ? Guid.Empty : placementProfile.PositionPathSide.Id,
- PositionType = placementProfile.PositionType,
- PositionLevel = placementProfile.PositionLevel,
- //PositionEmployeeLevel = placementProfile.PositionLevel,
- PositionLineId = placementProfile.PositionLine == null ? Guid.Empty : placementProfile.PositionLine.Id,
- PositionLine = placementProfile.PositionLine == null ? "" : placementProfile.PositionLine.Name,
- PosNo = placementProfile.OrganizationPosition!.PositionNumber,
-
- IsVerified = true,
- IsProbation = true,
- Physical = "",
- Ability = "",
- AvatarRef = "",
- GovAgeAbsent = 0,
- GovAgePlus = 0,
- EntryStatus = "",
- IsTransfer = false,
- IsActive = true,
- IsLeave = false,
- VerifiedUser = "",
- FirstNameOld = "",
- LastNameOld = "",
- // CoupleLive = false,
- // FatherLive = false,
- // MotherLive = false,
- CreatedUser = "",
-
- Educations = new List(),
- Certificates = new List(),
- Salaries = new List(),
- CreatedAt = DateTime.Now,
- CreatedFullName = FullName ?? "System Administrator",
- CreatedUserId = UserId ?? "",
- LastUpdatedAt = DateTime.Now,
- LastUpdateFullName = FullName ?? "System Administrator",
- LastUpdateUserId = UserId ?? "",
-
- // organization
- OrganizationShortNameId = placementProfile.OrganizationPosition!.Organization!.OrganizationShortName!.Id,
- OrganizationShortName = placementProfile.OrganizationPosition!.Organization!.OrganizationShortName!.Name,
- OrganizationOrganizationId = placementProfile.OrganizationPosition!.Organization!.OrganizationOrganization!.Id,
- OrganizationOrganization = placementProfile.OrganizationPosition!.Organization!.OrganizationOrganization!.Name,
- OcId = placementProfile.OrganizationPosition!.Organization!.Id,
- Oc = _organizationCommonRepository.GetOrganizationNameFullPath(placementProfile.OrganizationPosition!.Organization!.Id, false, false, "/"),
-
- };
+ client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
+ var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
+ var _res = await client.PostAsJsonAsync(apiUrl, new
+ {
+ rank = string.Empty,
+ prefix = placementProfile.Prefix.Name == null ? string.Empty : placementProfile.Prefix.Name,
+ firstName = placementProfile.Firstname == null ? string.Empty : placementProfile.Firstname,
+ lastName = placementProfile.Lastname == null ? string.Empty : placementProfile.Lastname,
+ citizenId = placementProfile.CitizenId == null ? string.Empty : placementProfile.CitizenId,
+ position = placementProfile.positionName == null ? string.Empty : placementProfile.positionName,
+ posLevelId = placementProfile.posLevelId == null ? string.Empty : placementProfile.posLevelId,
+ posTypeId = placementProfile.posTypeId == null ? string.Empty : placementProfile.posTypeId,
+ email = placementProfile.Email == null ? string.Empty : placementProfile.Email,
+ phone = placementProfile.MobilePhone == null ? string.Empty : placementProfile.MobilePhone,
+ keycloak = string.Empty,
+ isProbation = false,
+ isLeave = false,
+ dateRetire = (DateTime?)null,
+ dateAppoint = placementProfile.RecruitDate == null ? (DateTime?)null : placementProfile.RecruitDate,
+ dateStart = (DateTime?)null,
+ govAgeAbsent = 0,
+ govAgePlus = 0,
+ birthDate = placementProfile.DateOfBirth == null ? (DateTime?)null : placementProfile.DateOfBirth,
+ reasonSameDate = (DateTime?)null,
+ ethnicity = placementProfile.Race == null ? string.Empty : placementProfile.Race,
+ telephoneNumber = placementProfile.Telephone == null ? string.Empty : placementProfile.Telephone,
+ nationality = placementProfile.Nationality == null ? string.Empty : placementProfile.Nationality,
+ gender = placementProfile.Gender == null ? string.Empty : placementProfile.Gender.Name,
+ relationship = placementProfile.Relationship == null ? string.Empty : placementProfile.Relationship.Name,
+ religion = placementProfile.Religion == null ? string.Empty : placementProfile.Religion.Name,
+ bloodGroup = string.Empty,
+ registrationAddress = placementProfile.RegistAddress == null ? string.Empty : placementProfile.RegistAddress,
+ registrationProvinceId = (String?)null,
+ registrationDistrictId = (String?)null,
+ registrationSubDistrictId = (String?)null,
+ registrationZipCode = placementProfile.RegistZipCode == null ? string.Empty : placementProfile.RegistZipCode,
+ currentAddress = placementProfile.CurrentAddress == null ? string.Empty : placementProfile.CurrentAddress,
+ currentProvinceId = (String?)null,
+ currentDistrictId = (String?)null,
+ currentSubDistrictId = (String?)null,
+ currentZipCode = placementProfile.CurrentZipCode == null ? string.Empty : placementProfile.CurrentZipCode,
+ });
+ var _result = await _res.Content.ReadAsStringAsync();
+ profileId = JsonConvert.DeserializeObject(_result).result;
+ }
// add profile education
- foreach (var edu in placementProfile.PlacementEducations)
+ ////foreach (var edu in placementProfile.PlacementEducations)
+ ////{
+ //// profile.Educations.Add(new ProfileEducation
+ //// {
+ //// Country = edu.Country,
+ //// Degree = edu.Degree,
+ //// Duration = edu.Duration,
+ //// DurationYear = edu.DurationYear == null ? 0 : edu.DurationYear.Value,
+ //// EducationLevelId = edu.EducationLevel == null ? Guid.Empty : edu.EducationLevel.Id,
+ //// EducationLevel = edu.EducationLevel == null ? "" : edu.EducationLevel.Name,
+ //// StartDate = edu.StartDate,
+ //// EndDate = edu.EndDate,
+ //// Field = edu.Field,
+ //// FinishDate = edu.FinishDate,
+ //// FundName = edu.FundName,
+ //// Gpa = edu.Gpa,
+ //// Institute = edu.Institute,
+ //// IsActive = true,
+ //// CreatedAt = DateTime.Now,
+ //// CreatedFullName = FullName ?? "System Administrator",
+ //// CreatedUserId = UserId ?? "",
+ //// LastUpdatedAt = DateTime.Now,
+ //// LastUpdateFullName = FullName ?? "System Administrator",
+ //// LastUpdateUserId = UserId ?? "",
+ //// });
+ ////}
+
+ if (placementProfile.PlacementEducations != null)
{
- profile.Educations.Add(new ProfileEducation
+ var apiUrlEdu = $"{_configuration["API"]}/org/profile/educations";
+ using (var client = new HttpClient())
{
- Country = edu.Country,
- Degree = edu.Degree,
- Duration = edu.Duration,
- DurationYear = edu.DurationYear == null ? 0 : edu.DurationYear.Value,
- EducationLevelId = edu.EducationLevel == null ? Guid.Empty : edu.EducationLevel.Id,
- EducationLevel = edu.EducationLevel == null ? "" : edu.EducationLevel.Name,
- StartDate = edu.StartDate,
- EndDate = edu.EndDate,
- Field = edu.Field,
- FinishDate = edu.FinishDate,
- FundName = edu.FundName,
- Gpa = edu.Gpa,
- Institute = edu.Institute,
- IsActive = true,
- CreatedAt = DateTime.Now,
- CreatedFullName = FullName ?? "System Administrator",
- CreatedUserId = UserId ?? "",
- LastUpdatedAt = DateTime.Now,
- LastUpdateFullName = FullName ?? "System Administrator",
- LastUpdateUserId = UserId ?? "",
- });
+ client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
+ foreach (var edu in placementProfile.PlacementEducations)
+ {
+ var _res = await client.PostAsJsonAsync(apiUrlEdu, new
+ {
+ profileId = profileId,
+ country = edu.Country == null ? string.Empty : edu.Country,
+ degree = edu.Degree == null ? string.Empty : edu.Degree,
+ duration = edu.Duration == null ? string.Empty : edu.Duration,
+ durationYear = edu.DurationYear == null ? 0 : edu.DurationYear,
+ field = edu.Field == null ? string.Empty : edu.Field,
+ finishDate = edu.FinishDate == null ? (DateTime?)null : edu.FinishDate,
+ fundName = edu.FundName == null ? string.Empty : edu.FundName,
+ gpa = edu.Gpa == null ? string.Empty : edu.Gpa,
+ institute = edu.Institute == null ? string.Empty : edu.Institute,
+ other = edu.Other == null ? string.Empty : edu.Other,
+ startDate = edu.StartDate == null ? (DateTime?)null : edu.StartDate,
+ endDate = edu.EndDate == null ? (DateTime?)null : edu.EndDate,
+ educationLevel = edu.EducationLevel == null ? string.Empty : edu.EducationLevel.Name,
+ educationLevelId = string.Empty,
+ positionPath = edu.PositionPath == null ? null : edu.PositionPath,
+ positionPathId = string.Empty,
+ isDate = edu.IsDate,
+ isEducation = edu.IsEducation,
+ note = string.Empty,
+ });
+ var _result = await _res.Content.ReadAsStringAsync();
+ }
+ }
}
// add profile certificate
- foreach (var cert in placementProfile.PlacementCertificates)
+ ////foreach (var cert in placementProfile.PlacementCertificates)
+ ////{
+ //// profile.Certificates.Add(new ProfileCertificate
+ //// {
+ //// CertificateNo = cert.CertificateNo,
+ //// IssueDate = cert.IssueDate,
+ //// Issuer = cert.Issuer,
+ //// CertificateType = cert.CertificateType,
+ //// ExpireDate = cert.ExpireDate,
+ //// IsActive = true,
+ //// CreatedAt = DateTime.Now,
+ //// CreatedFullName = FullName ?? "System Administrator",
+ //// CreatedUserId = UserId ?? "",
+ //// LastUpdatedAt = DateTime.Now,
+ //// LastUpdateFullName = FullName ?? "System Administrator",
+ //// LastUpdateUserId = UserId ?? "",
+ //// });
+ ////}
+
+ if (placementProfile.PlacementCertificates != null)
{
- profile.Certificates.Add(new ProfileCertificate
+ var apiUrlCer = $"{_configuration["API"]}/org/profile/certificate";
+ using (var client = new HttpClient())
{
- CertificateNo = cert.CertificateNo,
- IssueDate = cert.IssueDate,
- Issuer = cert.Issuer,
- CertificateType = cert.CertificateType,
- ExpireDate = cert.ExpireDate,
- IsActive = true,
- CreatedAt = DateTime.Now,
- CreatedFullName = FullName ?? "System Administrator",
- CreatedUserId = UserId ?? "",
- LastUpdatedAt = DateTime.Now,
- LastUpdateFullName = FullName ?? "System Administrator",
- LastUpdateUserId = UserId ?? "",
- });
+ client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
+ foreach (var cer in placementProfile.PlacementCertificates)
+ {
+ var _res = await client.PostAsJsonAsync(apiUrlCer, new
+ {
+ profileId = profileId,
+ expireDate = cer.ExpireDate == null ? (DateTime?)null : cer.ExpireDate,
+ issueDate = cer.IssueDate == null ? (DateTime?)null : cer.IssueDate,
+ certificateNo = cer.CertificateNo == null ? string.Empty : cer.CertificateNo,
+ certificateType = cer.CertificateType == null ? string.Empty : cer.CertificateType,
+ issuer = cer.Issuer == null ? string.Empty : cer.Issuer,
+ });
+ var _result = await _res.Content.ReadAsStringAsync();
+ }
+ }
}
// add profile document
- foreach (var doc in placementProfile.PlacementProfileDocs)
- {
- profile.Papers.Add(new ProfilePaper
- {
- CategoryName = "Profile Documents",
- Document = doc.Document,
- Detail = doc.Document.FileName,
- CreatedAt = DateTime.Now,
- CreatedFullName = FullName ?? "System Administrator",
- CreatedUserId = UserId ?? "",
- LastUpdatedAt = DateTime.Now,
- LastUpdateFullName = FullName ?? "System Administrator",
- LastUpdateUserId = UserId ?? "",
- });
- }
+ ////foreach (var doc in placementProfile.PlacementProfileDocs)
+ ////{
+ //// profile.Papers.Add(new ProfilePaper
+ //// {
+ //// CategoryName = "Profile Documents",
+ //// Document = doc.Document,
+ //// Detail = doc.Document.FileName,
+ //// CreatedAt = DateTime.Now,
+ //// CreatedFullName = FullName ?? "System Administrator",
+ //// CreatedUserId = UserId ?? "",
+ //// LastUpdatedAt = DateTime.Now,
+ //// LastUpdateFullName = FullName ?? "System Administrator",
+ //// LastUpdateUserId = UserId ?? "",
+ //// });
+ ////}
+
// add profile salary
- var oc = _dbContext.Set()
- .FirstOrDefault(x => x.Id == placementProfile.OrganizationPosition!.Organization!.Id);
+ ////var oc = _dbContext.Set()
+ //// .FirstOrDefault(x => x.Id == placementProfile.OrganizationPosition!.Organization!.Id);
- var position = placementProfile.PositionPath;
+ ////var position = placementProfile.PositionPath;
- var positionNumber = placementProfile.PositionNumber;
+ ////var positionNumber = placementProfile.PositionNumber;
- var positionType = placementProfile.PositionType;
+ ////var positionType = placementProfile.PositionType;
- var positionLevel = placementProfile.PositionLevel;
+ ////var positionLevel = placementProfile.PositionLevel;
- var salary = new ProfileSalary
+ ////var salary = new ProfileSalary
+ ////{
+ //// Order = 1,
+ //// Date = command.CommandAffectDate,
+ //// Amount = placementProfile.Amount == null ? 0 : placementProfile.Amount,
+ //// PositionSalaryAmount = placementProfile.PositionSalaryAmount == null ? 0 : placementProfile.PositionSalaryAmount,
+ //// MouthSalaryAmount = placementProfile.MouthSalaryAmount == null ? 0 : placementProfile.MouthSalaryAmount,
+ //// SalaryClass = "",
+ //// SalaryRef = "บรรจุและแต่งตั้งผู้สอบแข่งขันได้วุฒิ คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}",
+
+ //// OcId = oc == null ? Guid.Empty : oc.Id,
+
+ //// PositionId = position!.Id,
+
+ //// PositionLevel = placementProfile.PositionLevel,
+ //// PositionLineId = placementProfile.PositionLine!.Id,
+ //// PositionTypeId = placementProfile.PositionType!.Id,
+ //// OrganizationShortNameId = placementProfile.OrganizationPosition!.Organization!.OrganizationShortName!.Id,
+ //// PosNoId = positionNumber!.Id,
+
+ //// CommandNo = $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()}",
+ //// RefCommandNo = $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()}",
+ //// CommandTypeName = command.CommandType.Name,
+
+
+ //// PositionEmployeeGroupId = null,
+ //// PositionEmployeeLevelId = null,
+ //// PositionEmployeePositionId = null,
+ //// PositionEmployeePositionSideId = null,
+ //// PosNoEmployee = "",
+
+
+ //// PositionPathSideId = placementProfile.PositionPathSide! == null ? null : placementProfile.PositionPathSide!.Id,
+ //// PositionExecutiveId = placementProfile.OrganizationPosition!.PositionMaster!.PositionExecutive! == null ? null : placementProfile.OrganizationPosition!.PositionMaster!.PositionExecutive!.Id,
+ //// PositionExecutiveSideId = placementProfile.OrganizationPosition!.PositionMaster!.PositionExecutiveSide! == null ? null : placementProfile.OrganizationPosition!.PositionMaster!.PositionExecutiveSide!.Id,
+
+ //// IsActive = true,
+ //// CreatedAt = DateTime.Now,
+ //// CreatedFullName = FullName ?? "System Administrator",
+ //// CreatedUserId = UserId ?? "",
+ //// LastUpdatedAt = DateTime.Now,
+ //// LastUpdateFullName = FullName ?? "System Administrator",
+ //// LastUpdateUserId = UserId ?? "",
+
+ ////};
+
+ var apiUrlSalary = $"{_configuration["API"]}/org/profile/salary";
+ using (var client = new HttpClient())
{
- Order = 1,
- Date = command.CommandAffectDate,
- Amount = placementProfile.Amount == null ? 0 : placementProfile.Amount,
- PositionSalaryAmount = placementProfile.PositionSalaryAmount == null ? 0 : placementProfile.PositionSalaryAmount,
- MouthSalaryAmount = placementProfile.MouthSalaryAmount == null ? 0 : placementProfile.MouthSalaryAmount,
- SalaryClass = "",
- SalaryRef = "บรรจุและแต่งตั้งผู้สอบแข่งขันได้วุฒิ คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}",
+ client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
+ var _res = await client.PostAsJsonAsync(apiUrlSalary, new
+ {
+ profileId = profileId,
+ date = command.CommandAffectDate == null ? (DateTime?)null : command.CommandAffectDate,
+ amount = placementProfile.Amount == null ? null : placementProfile.Amount,
+ positionSalaryAmount = placementProfile.PositionSalaryAmount == null ? null : placementProfile.PositionSalaryAmount,
+ mouthSalaryAmount = placementProfile.MouthSalaryAmount == null ? null : placementProfile.MouthSalaryAmount,
+ posNo = placementProfile.PosNumber == null ? string.Empty : placementProfile.PosNumber.ToString(),
+ position = placementProfile.positionName == null ? string.Empty : placementProfile.positionName,
+ positionLine = string.Empty,
+ positionPathSide = string.Empty,
+ positionExecutive = string.Empty,
+ positionType = placementProfile.posTypeName == null ? string.Empty : placementProfile.posTypeName,
+ positionLevel = placementProfile.PositionLevel == null ? string.Empty : placementProfile.PositionLevel.Name,
+ refCommandNo = string.Empty,
+ templateDoc = string.Empty,
+ });
+ var _result = await _res.Content.ReadAsStringAsync();
+ }
- OcId = oc == null ? Guid.Empty : oc.Id,
-
- PositionId = position!.Id,
-
- PositionLevel = placementProfile.PositionLevel,
- PositionLineId = placementProfile.PositionLine!.Id,
- PositionTypeId = placementProfile.PositionType!.Id,
- OrganizationShortNameId = placementProfile.OrganizationPosition!.Organization!.OrganizationShortName!.Id,
- PosNoId = positionNumber!.Id,
-
- CommandNo = $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()}",
- RefCommandNo = $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()}",
- CommandTypeName = command.CommandType.Name,
-
-
- PositionEmployeeGroupId = null,
- PositionEmployeeLevelId = null,
- PositionEmployeePositionId = null,
- PositionEmployeePositionSideId = null,
- PosNoEmployee = "",
-
-
- PositionPathSideId = placementProfile.PositionPathSide! == null ? null : placementProfile.PositionPathSide!.Id,
- PositionExecutiveId = placementProfile.OrganizationPosition!.PositionMaster!.PositionExecutive! == null ? null : placementProfile.OrganizationPosition!.PositionMaster!.PositionExecutive!.Id,
- PositionExecutiveSideId = placementProfile.OrganizationPosition!.PositionMaster!.PositionExecutiveSide! == null ? null : placementProfile.OrganizationPosition!.PositionMaster!.PositionExecutiveSide!.Id,
-
- IsActive = true,
- CreatedAt = DateTime.Now,
- CreatedFullName = FullName ?? "System Administrator",
- CreatedUserId = UserId ?? "",
- LastUpdatedAt = DateTime.Now,
- LastUpdateFullName = FullName ?? "System Administrator",
- LastUpdateUserId = UserId ?? "",
-
- };
//if (placementProfile.PositionPathSide! != null)
//{
@@ -2996,97 +3131,97 @@ namespace BMA.EHR.Application.Repositories.Commands
//}
// add profile position
- var profilePosition = new ProfilePosition
- {
- Profile = profile,
- OrganizationPosition = placementProfile.OrganizationPosition,
- IsActive = true,
- IsPublished = true,
- };
- _dbContext.Set().Add(profilePosition);
+ ////var profilePosition = new ProfilePosition
+ ////{
+ //// Profile = profile,
+ //// OrganizationPosition = placementProfile.OrganizationPosition,
+ //// IsActive = true,
+ //// IsPublished = true,
+ ////};
+ ////_dbContext.Set().Add(profilePosition);
- profile.Salaries.Add(salary);
+ ////profile.Salaries.Add(salary);
- _dbContext.Set().Add(profile);
+ ////_dbContext.Set().Add(profile);
// update placementstatus
placementProfile.PlacementStatus = "CONTAIN";
await _dbContext.SaveChangesAsync();
- // TODO: ต้องเปลี่ยนเป็น Email จริงนะ ตอนนี้ Hardcode อยู่
- // Send noti inbox and email
- var subject = $"คุณได้รับคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}";
- var body = $"คุณได้รับรรจุเป็นข้าราชการกรุงเทพมหานครสามัญ ตามคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}";
- _emailSenderService.SendMail(subject, body, "dev@frappet.com");
+ ////// TODO: ต้องเปลี่ยนเป็น Email จริงนะ ตอนนี้ Hardcode อยู่
+ ////// Send noti inbox and email
+ ////var subject = $"คุณได้รับคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}";
+ ////var body = $"คุณได้รับรรจุเป็นข้าราชการกรุงเทพมหานครสามัญ ตามคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}";
+ ////_emailSenderService.SendMail(subject, body, "dev@frappet.com");
- var inbox = new Inbox
- {
- Subject = $"คุณได้รับคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
- Body = $"คุณได้รับรรจุเป็นข้าราชการกรุงเทพมหานครสามัญ ตามคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
- ReceiverUserId = profile.Id,
- Payload = payload_str,
- };
- _dbContext.Set().Add(inbox);
+ ////var inbox = new Inbox
+ ////{
+ //// Subject = $"คุณได้รับคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
+ //// Body = $"คุณได้รับรรจุเป็นข้าราชการกรุงเทพมหานครสามัญ ตามคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
+ //// ReceiverUserId = profile.Id,
+ //// Payload = payload_str,
+ ////};
+ ////_dbContext.Set().Add(inbox);
- var noti = new Notification
- {
- Body = $"คุณได้รับรรจุเป็นข้าราชการกรุงเทพมหานครสามัญ ตามคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
- ReceiverUserId = profile.Id,
- Type = "LINK",
- Payload = payload_str,
- };
- _dbContext.Set().Add(noti);
- await _dbContext.SaveChangesAsync();
+ ////var noti = new Notification
+ ////{
+ //// Body = $"คุณได้รับรรจุเป็นข้าราชการกรุงเทพมหานครสามัญ ตามคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
+ //// ReceiverUserId = profile.Id,
+ //// Type = "LINK",
+ //// Payload = payload_str,
+ ////};
+ ////_dbContext.Set().Add(noti);
+ ////await _dbContext.SaveChangesAsync();
}
- // send cc noti inbox
- foreach (var cc in command.Deployments)
- {
- var pf = await _dbContext.Set().FirstOrDefaultAsync(x => x.CitizenId == cc.CitizenId);
- if (pf != null)
- {
- if (cc.IsSendInbox)
- {
- var inbox = new Inbox
- {
- Subject = $"คุณได้รับสำเนาคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
- Body = $"คำสั่งบรรจุเป็นข้าราชการกรุงเทพมหานครสามัญ คำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
- ReceiverUserId = pf.Id,
- Payload = payload_str,
- };
- _dbContext.Set().Add(inbox);
- }
+ //// send cc noti inbox
+ ////foreach (var cc in command.Deployments)
+ ////{
+ //// var pf = await _dbContext.Set().FirstOrDefaultAsync(x => x.CitizenId == cc.CitizenId);
+ //// if (pf != null)
+ //// {
+ //// if (cc.IsSendInbox)
+ //// {
+ //// var inbox = new Inbox
+ //// {
+ //// Subject = $"คุณได้รับสำเนาคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
+ //// Body = $"คำสั่งบรรจุเป็นข้าราชการกรุงเทพมหานครสามัญ คำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
+ //// ReceiverUserId = pf.Id,
+ //// Payload = payload_str,
+ //// };
+ //// _dbContext.Set().Add(inbox);
+ //// }
- if (cc.IsSendMail)
- {
- // TODO: ต้องเปลี่ยนเป็น Email จริงนะ ตอนนี้ Hardcode อยู่
- // Send noti inbox and email
- var subject = $"คุณได้รับสำเนาคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}";
- var body = $"คำสั่งบรรจุเป็นข้าราชการกรุงเทพมหานครสามัญ คำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}";
- _emailSenderService.SendMail(subject, body, "dev@frappet.com");
- }
+ //// if (cc.IsSendMail)
+ //// {
+ //// // TODO: ต้องเปลี่ยนเป็น Email จริงนะ ตอนนี้ Hardcode อยู่
+ //// // Send noti inbox and email
+ //// var subject = $"คุณได้รับสำเนาคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}";
+ //// var body = $"คำสั่งบรรจุเป็นข้าราชการกรุงเทพมหานครสามัญ คำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}";
+ //// _emailSenderService.SendMail(subject, body, "dev@frappet.com");
+ //// }
- var noti = new Notification
- {
- Body = $"คำสั่งบรรจุเป็นข้าราชการกรุงเทพมหานครสามัญ คำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
- ReceiverUserId = pf.Id,
- Type = "LINK",
- Payload = payload_str,
- };
- _dbContext.Set().Add(noti);
- }
- }
+ //// var noti = new Notification
+ //// {
+ //// Body = $"คำสั่งบรรจุเป็นข้าราชการกรุงเทพมหานครสามัญ คำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
+ //// ReceiverUserId = pf.Id,
+ //// Type = "LINK",
+ //// Payload = payload_str,
+ //// };
+ //// _dbContext.Set().Add(noti);
+ //// }
+ ////}
- // change command status
- var cmdStatus = await _dbContext.Set().FirstOrDefaultAsync(x => x.Sequence == 5);
- command.CommandStatusId = cmdStatus!.Id;
+ ////// change command status
+ ////var cmdStatus = await _dbContext.Set().FirstOrDefaultAsync(x => x.Sequence == 5);
+ ////command.CommandStatusId = cmdStatus!.Id;
- await _dbContext.SaveChangesAsync();
+ ////await _dbContext.SaveChangesAsync();
}
catch
{
diff --git a/BMA.EHR.Domain/Models/Placement/PlacementProfile.cs b/BMA.EHR.Domain/Models/Placement/PlacementProfile.cs
index e8920431..201abebe 100644
--- a/BMA.EHR.Domain/Models/Placement/PlacementProfile.cs
+++ b/BMA.EHR.Domain/Models/Placement/PlacementProfile.cs
@@ -7,6 +7,11 @@ using BMA.EHR.Domain.Models.Documents;
namespace BMA.EHR.Domain.Models.Placement
{
+ public class PlacementProfileId
+ {
+ [Comment("Id Profile")]
+ public string result { get; set; }
+ }
public class PlacementProfile : EntityBase
{