diff --git a/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs b/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs
index 7fb242e9..b6d18618 100644
--- a/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs
+++ b/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs
@@ -1497,6 +1497,9 @@ namespace BMA.EHR.Application.Repositories.Commands
case "C-PM-13":
await ExecuteCommand13Async(command);
break;
+ case "C-PM-14":
+ await ExecuteCommand14Async(command);
+ break;
case "C-PM-15":
await ExecuteCommand15Async(command);
break;
@@ -1515,6 +1518,9 @@ namespace BMA.EHR.Application.Repositories.Commands
case "C-PM-20":
await ExecuteCommand20Async(command);
break;
+ case "C-PM-21":
+ await ExecuteCommand21Async(command);
+ break;
default: throw new Exception(GlobalMessages.MethodForCommandTypeNotImplement);
}
@@ -1749,7 +1755,7 @@ namespace BMA.EHR.Application.Repositories.Commands
PositionSalaryAmount = placementProfile.PositionSalaryAmount == null ? 0 : placementProfile.PositionSalaryAmount,
MouthSalaryAmount = placementProfile.MouthSalaryAmount == null ? 0 : placementProfile.MouthSalaryAmount,
SalaryClass = "",
- SalaryRef = "บรรจุและแต่งตั้งผู้สอบแข่งขันได้วุฒิ คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}",
+ SalaryRef = "บรรจุและแต่งตั้งผู้สอบแข่งขันได้วุฒิ คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}",
OcId = oc == null ? Guid.Empty : oc.Id,
@@ -1760,7 +1766,7 @@ namespace BMA.EHR.Application.Repositories.Commands
OrganizationShortNameId = placementProfile.OrganizationPosition!.Organization!.OrganizationShortName!.Id,
PosNoId = positionNumber!.Id,
- CommandNo = $"{command.CommandNo}/{command.CommandYear}",
+ CommandNo = $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()}",
CommandTypeName = command.CommandType.Name,
@@ -1822,14 +1828,14 @@ namespace BMA.EHR.Application.Repositories.Commands
// TODO: ต้องเปลี่ยนเป็น Email จริงนะ ตอนนี้ Hardcode อยู่
// Send noti inbox and email
- var subject = $"คุณได้รับคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}";
+ 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} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
+ 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 = "",
@@ -2018,7 +2024,7 @@ namespace BMA.EHR.Application.Repositories.Commands
OrganizationShortNameId = placementProfile.OrganizationPosition!.Organization!.OrganizationShortName!.Id,
PosNoId = positionNumber!.Id,
- CommandNo = $"{command.CommandNo}/{command.CommandYear}",
+ CommandNo = $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()}",
CommandTypeName = command.CommandType.Name,
PositionEmployeeGroupId = null,
@@ -2249,7 +2255,7 @@ namespace BMA.EHR.Application.Repositories.Commands
OrganizationShortNameId = placementProfile.OrganizationPosition!.Organization!.OrganizationShortName!.Id,
PosNoId = positionNumber!.Id,
- CommandNo = $"{command.CommandNo}/{command.CommandYear}",
+ CommandNo = $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()}",
CommandTypeName = command.CommandType.Name,
PositionEmployeeGroupId = null,
@@ -2461,7 +2467,7 @@ namespace BMA.EHR.Application.Repositories.Commands
OrganizationShortNameId = placementProfile.OrganizationPosition!.Organization!.OrganizationShortName!.Id,
PosNoId = positionNumber!.Id,
- CommandNo = $"{command.CommandNo}/{command.CommandYear}",
+ CommandNo = $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()}",
CommandTypeName = command.CommandType.Name,
PositionEmployeeGroupId = null,
@@ -2673,7 +2679,7 @@ namespace BMA.EHR.Application.Repositories.Commands
OrganizationShortNameId = placementProfile.OrganizationPosition!.Organization!.OrganizationShortName!.Id,
PosNoId = positionNumber!.Id,
- CommandNo = $"{command.CommandNo}/{command.CommandYear}",
+ CommandNo = $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()}",
CommandTypeName = command.CommandType.Name,
PositionEmployeeGroupId = null,
@@ -2885,7 +2891,7 @@ namespace BMA.EHR.Application.Repositories.Commands
OrganizationShortNameId = placementProfile.OrganizationPosition!.Organization!.OrganizationShortName!.Id,
PosNoId = positionNumber!.Id,
- CommandNo = $"{command.CommandNo}/{command.CommandYear}",
+ CommandNo = $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()}",
CommandTypeName = command.CommandType.Name,
PositionEmployeeGroupId = null,
@@ -3102,7 +3108,7 @@ namespace BMA.EHR.Application.Repositories.Commands
OrganizationShortNameId = placementProfile.OrganizationPosition!.Organization!.OrganizationShortName!.Id,
PosNoId = positionNumber!.Id,
- CommandNo = $"{command.CommandNo}/{command.CommandYear}",
+ CommandNo = $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()}",
CommandTypeName = command.CommandType.Name,
PositionEmployeeGroupId = null,
@@ -3319,7 +3325,7 @@ namespace BMA.EHR.Application.Repositories.Commands
OrganizationShortNameId = placementProfile.OrganizationPosition!.Organization!.OrganizationShortName!.Id,
PosNoId = positionNumber!.Id,
- CommandNo = $"{command.CommandNo}/{command.CommandYear}",
+ CommandNo = $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()}",
CommandTypeName = command.CommandType.Name,
PositionEmployeeGroupId = null,
@@ -3464,7 +3470,7 @@ namespace BMA.EHR.Application.Repositories.Commands
PositionSalaryAmount = lastSarary.PositionSalaryAmount,
MouthSalaryAmount = lastSarary.MouthSalaryAmount,
SalaryClass = "",
- SalaryRef = "คำสั่งแต่งตั้งคณะกรรมการประเมินผลการทดลองปฏิบัติหน้าที่ราชการ คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}",
+ SalaryRef = "คำสั่งแต่งตั้งคณะกรรมการประเมินผลการทดลองปฏิบัติหน้าที่ราชการ คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}",
OcId = lastSarary.OcId,
@@ -3512,14 +3518,14 @@ namespace BMA.EHR.Application.Repositories.Commands
// TODO: ต้องเปลี่ยนเป็น Email จริงนะ ตอนนี้ Hardcode อยู่
// Send noti inbox and email
- var subject = $"คุณได้รับคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}";
+ 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} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
+ Subject = $"คุณได้รับคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
Body = $"คำสั่งแต่งตั้งคณะกรรมการประเมินผลการทดลองปฏิบัติหน้าที่ราชการ เลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
ReceiverUserId = data.Id,
Payload = "",
@@ -3622,7 +3628,7 @@ namespace BMA.EHR.Application.Repositories.Commands
PositionSalaryAmount = lastSarary.PositionSalaryAmount,
MouthSalaryAmount = lastSarary.MouthSalaryAmount,
SalaryClass = "",
- SalaryRef = "คำสั่งให้ข้าราชการที่มีผลการทดลองปฏิบัติหน้าที่ราชการไม่ต่ำกว่ามาตรฐานที่กำหนดรับราชการต่อไป คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}",
+ SalaryRef = "คำสั่งให้ข้าราชการที่มีผลการทดลองปฏิบัติหน้าที่ราชการไม่ต่ำกว่ามาตรฐานที่กำหนดรับราชการต่อไป คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}",
OcId = lastSarary.OcId,
@@ -3670,14 +3676,14 @@ namespace BMA.EHR.Application.Repositories.Commands
// TODO: ต้องเปลี่ยนเป็น Email จริงนะ ตอนนี้ Hardcode อยู่
// Send noti inbox and email
- var subject = $"คุณได้รับคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}";
+ 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} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
+ Subject = $"คุณได้รับคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
Body = $"คำสั่งให้ข้าราชการที่มีผลการทดลองปฏิบัติหน้าที่ราชการไม่ต่ำกว่ามาตรฐานที่กำหนดรับราชการต่อไป เลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
ReceiverUserId = data.Id,
Payload = "",
@@ -3783,7 +3789,7 @@ namespace BMA.EHR.Application.Repositories.Commands
PositionSalaryAmount = lastSarary.PositionSalaryAmount,
MouthSalaryAmount = lastSarary.MouthSalaryAmount,
SalaryClass = "",
- SalaryRef = "คำสั่งให้ข้าราชการออกจากราชการเพราะผลการทดลองปฏิบัติหน้าที่ราชการต่ำกว่ามาตรฐานที่กำหนด คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}",
+ SalaryRef = "คำสั่งให้ข้าราชการออกจากราชการเพราะผลการทดลองปฏิบัติหน้าที่ราชการต่ำกว่ามาตรฐานที่กำหนด คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}",
OcId = lastSarary.OcId,
@@ -3831,14 +3837,14 @@ namespace BMA.EHR.Application.Repositories.Commands
// TODO: ต้องเปลี่ยนเป็น Email จริงนะ ตอนนี้ Hardcode อยู่
// Send noti inbox and email
- var subject = $"คุณได้รับคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}";
+ 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} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
+ Subject = $"คุณได้รับคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
Body = $"คุณได้รับคำสั่งให้ข้าราชการออกจากราชการเพราะผลการทดลองปฏิบัติหน้าที่ราชการต่ำกว่ามาตรฐานที่กำหนด เลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
ReceiverUserId = data.Id,
Payload = "",
@@ -3946,7 +3952,7 @@ namespace BMA.EHR.Application.Repositories.Commands
PositionSalaryAmount = lastSarary.PositionSalaryAmount,
MouthSalaryAmount = lastSarary.MouthSalaryAmount,
SalaryClass = "",
- SalaryRef = "คำสั่งให้โอนข้าราชการกรุงเทพมหานครสามัญ คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}",
+ SalaryRef = "คำสั่งให้โอนข้าราชการกรุงเทพมหานครสามัญ คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}",
OcId = lastSarary.OcId,
@@ -3994,14 +4000,14 @@ namespace BMA.EHR.Application.Repositories.Commands
// TODO: ต้องเปลี่ยนเป็น Email จริงนะ ตอนนี้ Hardcode อยู่
// Send noti inbox and email
- var subject = $"คุณได้รับคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}";
+ 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} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
+ Subject = $"คุณได้รับคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
Body = $"คำสั่งให้โอนข้าราชการกรุงเทพมหานครสามัญ เลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
ReceiverUserId = data.Id,
Payload = "",
@@ -4070,6 +4076,337 @@ namespace BMA.EHR.Application.Repositories.Commands
}
}
+ ///
+ /// C-PM-14 - คำสั่งให้โอนข้าราชการกรุงเทพมหานครสามัญ
+ ///
+ /// object ของรายการคำสั่ง
+ ///
+ private async Task ExecuteCommand14Async(Command command)
+ {
+ try
+ {
+ // create new profile
+ foreach (var recv in command.Receivers)
+ {
+ // query placement Profile
+ var placementProfile = await _dbContext.Set()
+ .Include(x => x.Prefix)
+ //.Include(x => x.FatherPrefix)
+ //.Include(x => x.MotherPrefix)
+ //.Include(x => x.MarryPrefix)
+ .Include(x => x.Gender)
+ .Include(x => x.Relationship)
+ .Include(x => x.BloodGroup)
+ .Include(x => x.Religion)
+
+ //.Include(x => x.RegistSubDistrict)
+ //.Include(x => x.RegistDistrict)
+ //.Include(x => x.RegistProvince)
+ //.Include(x => x.CurrentSubDistrict)
+ //.Include(x => x.CurrentDistrict)
+ //.Include(x => x.CurrentProvince)
+
+ .Include(x => x.PositionPath)
+ .Include(x => x.PositionPathSide)
+ .Include(x => x.PositionType)
+ .Include(x => x.PositionLine)
+ .Include(x => x.PositionLevel)
+ .Include(x => x.PositionNumber)
+
+ //.Include(x => x.PlacementCertificates)
+ //.Include(x => x.PlacementEducations)
+ //.ThenInclude(x => x.EducationLevel)
+
+ .Include(x => x.OrganizationPosition)
+ .ThenInclude(x => x.Organization)
+ .ThenInclude(x => x.OrganizationShortName)
+
+ .Include(x => x.OrganizationPosition)
+ .ThenInclude(x => x.PositionMaster)
+ .ThenInclude(x => x.PositionExecutive)
+
+ .Include(x => x.OrganizationPosition)
+ .ThenInclude(x => x.PositionMaster)
+ .ThenInclude(x => x.PositionExecutiveSide)
+
+ .Include(x => x.OrganizationPosition)
+ .ThenInclude(x => x.PositionMaster)
+ .ThenInclude(x => x.PositionLine)
+
+ .Include(x => x.OrganizationPosition)
+ .ThenInclude(x => x.Organization)
+ .ThenInclude(x => x.OrganizationOrganization)
+
+ .FirstOrDefaultAsync(x => x.Id == recv.RefPlacementProfileId);
+
+ if (placementProfile == null)
+ throw new Exception("Invalid placement profile: " + recv.RefPlacementProfileId);
+
+ // ใส่ฟีลจากข้อมูล
+ 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,
+ RelationshipId = placementProfile.Relationship == null ? Guid.Empty : placementProfile.Relationship!.Id,
+ TelephoneNumber = "",
+ 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,
+
+ //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,
+
+ //FatherPrefixId = placementProfile.FatherPrefix == null ? Guid.Empty : placementProfile.FatherPrefix.Id,
+ //FatherFirstName = placementProfile.FatherFirstName,
+ //FatherLastName = placementProfile.FatherLastName,
+ //FatherCareer = placementProfile.FatherOccupation,
+
+ //MotherPrefixId = placementProfile.MotherPrefix == null ? Guid.Empty : placementProfile.MotherPrefix.Id,
+ //MotherFirstName = placementProfile.MotherFirstName,
+ //MotherLastName = placementProfile.MotherLastName,
+ //MotherCareer = placementProfile.MotherOccupation,
+
+ //CouplePrefixId = placementProfile.MarryPrefix == null ? Guid.Empty : placementProfile.MarryPrefix.Id,
+ //CoupleFirstName = placementProfile.MarryFirstName,
+ //CoupleLastName = placementProfile.MarryLastName,
+ //CoupleCareer = placementProfile.MarryOccupation,
+
+ 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,
+ OcId = placementProfile.OrganizationPosition!.Organization!.Id,
+ Oc = _organizationCommonRepository.GetOrganizationNameFullPath(placementProfile.OrganizationPosition!.Organization!.Id, false, false, "/"),
+
+ };
+
+ // add profile salary
+
+ var oc = _dbContext.Set()
+ .FirstOrDefault(x => x.Id == placementProfile.OrganizationPosition!.Organization!.Id);
+
+ var position = placementProfile.PositionPath;
+
+ var positionNumber = placementProfile.PositionNumber;
+
+ var positionType = placementProfile.PositionType;
+
+ var positionLevel = placementProfile.PositionLevel;
+
+
+ var salary = new ProfileSalary
+ {
+ Order = 1,
+ Date = command.CommandAffectDate,
+ Amount = recv.Amount == null ? 0 : recv.Amount,
+ PositionSalaryAmount = recv.PositionSalaryAmount == null ? 0 : recv.PositionSalaryAmount,
+ MouthSalaryAmount = recv.MouthSalaryAmount == null ? 0 : recv.MouthSalaryAmount,
+ SalaryClass = "",
+ SalaryRef = "รับโอนข้าราชการกรุงเทพมหานครสามัญ คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}",
+
+ OcId = oc == null ? Guid.Empty : oc.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()}",
+ 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)
+ //{
+ // salary.PositionPathSideId = placementProfile.PositionPathSide!.Id;
+ //}
+ //else
+
+ //if (placementProfile.OrganizationPosition!.PositionMaster!.PositionExecutive! != null)
+ //{
+ // salary.PositionExecutiveId = placementProfile.OrganizationPosition!.PositionMaster!.PositionExecutive!.Id;
+ //}
+
+ //if (placementProfile.OrganizationPosition!.PositionMaster!.PositionExecutiveSide! != null)
+ //{
+ // salary.PositionExecutiveSideId = placementProfile.OrganizationPosition!.PositionMaster!.PositionExecutiveSide!.Id;
+ //}
+
+ // add profile position
+ var profilePosition = new ProfilePosition
+ {
+ Profile = profile,
+ OrganizationPosition = placementProfile.OrganizationPosition,
+ IsActive = true,
+ IsPublished = true,
+ };
+ _dbContext.Set().Add(profilePosition);
+
+ profile.Salaries.Add(salary);
+
+ _dbContext.Set().Add(profile);
+
+ // update placementstatus
+ placementProfile.Status = "DONE";
+
+ 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");
+
+
+ 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 = "",
+ };
+ _dbContext.Set().Add(inbox);
+
+ var noti = new Notification
+ {
+ Body = $"คุณได้รับโอนเป็นข้าราชการกรุงเทพมหานครสามัญ ตามคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
+ ReceiverUserId = profile.Id,
+ Type = "",
+ Payload = "",
+ };
+ _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 = "",
+ };
+ _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");
+ }
+
+
+ var noti = new Notification
+ {
+ Body = $"คำสั่งรับโอนข้าราชการกรุงเทพมหานครสามัญ คำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
+ ReceiverUserId = pf.Id,
+ Type = "",
+ Payload = "",
+ };
+ _dbContext.Set().Add(noti);
+ }
+ }
+
+ // change command status
+ var cmdStatus = await _dbContext.Set().FirstOrDefaultAsync(x => x.Sequence == 5);
+ command.CommandStatusId = cmdStatus!.Id;
+
+ await _dbContext.SaveChangesAsync();
+ }
+ catch
+ {
+ throw;
+ }
+ }
+
///
/// C-PM-15 - คำสั่งให้ช่วยราชการ
///
@@ -4109,7 +4446,7 @@ namespace BMA.EHR.Application.Repositories.Commands
PositionSalaryAmount = lastSarary.PositionSalaryAmount,
MouthSalaryAmount = lastSarary.MouthSalaryAmount,
SalaryClass = "",
- SalaryRef = "คำสั่งให้ช่วยราชการ คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}",
+ SalaryRef = "คำสั่งให้ช่วยราชการ คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}",
OcId = lastSarary.OcId,
@@ -4156,14 +4493,14 @@ namespace BMA.EHR.Application.Repositories.Commands
// TODO: ต้องเปลี่ยนเป็น Email จริงนะ ตอนนี้ Hardcode อยู่
// Send noti inbox and email
- var subject = $"คุณได้รับคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}";
+ 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} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
+ Subject = $"คุณได้รับคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
Body = $"คำสั่งให้ช่วยราชการ เลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
ReceiverUserId = data.Profile.Id,
Payload = "",
@@ -4271,7 +4608,7 @@ namespace BMA.EHR.Application.Repositories.Commands
PositionSalaryAmount = lastSarary.PositionSalaryAmount,
MouthSalaryAmount = lastSarary.MouthSalaryAmount,
SalaryClass = "",
- SalaryRef = "คำสั่งส่งตัวกลับ คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}",
+ SalaryRef = "คำสั่งส่งตัวกลับ คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}",
OcId = lastSarary.OcId,
@@ -4318,14 +4655,14 @@ namespace BMA.EHR.Application.Repositories.Commands
// TODO: ต้องเปลี่ยนเป็น Email จริงนะ ตอนนี้ Hardcode อยู่
// Send noti inbox and email
- var subject = $"คุณได้รับคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}";
+ 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} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
+ Subject = $"คุณได้รับคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
Body = $"คำสั่งส่งตัวกลับ เลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
ReceiverUserId = data.Profile.Id,
Payload = "",
@@ -4433,7 +4770,7 @@ namespace BMA.EHR.Application.Repositories.Commands
PositionSalaryAmount = lastSarary.PositionSalaryAmount,
MouthSalaryAmount = lastSarary.MouthSalaryAmount,
SalaryClass = "",
- SalaryRef = "คำสั่งอนุญาตให้ข้าราชการลาออกจากราชการ คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}",
+ SalaryRef = "คำสั่งอนุญาตให้ข้าราชการลาออกจากราชการ คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}",
OcId = lastSarary.OcId,
@@ -4481,14 +4818,14 @@ namespace BMA.EHR.Application.Repositories.Commands
// TODO: ต้องเปลี่ยนเป็น Email จริงนะ ตอนนี้ Hardcode อยู่
// Send noti inbox and email
- var subject = $"คุณได้รับคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}";
+ 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} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
+ Subject = $"คุณได้รับคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
Body = $"คุณได้รับคำสั่งอนุญาตให้ข้าราชการลาออกจากราชการ เลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
ReceiverUserId = data.Profile.Id,
Payload = "",
@@ -4596,7 +4933,7 @@ namespace BMA.EHR.Application.Repositories.Commands
PositionSalaryAmount = lastSarary.PositionSalaryAmount,
MouthSalaryAmount = lastSarary.MouthSalaryAmount,
SalaryClass = "",
- SalaryRef = "คำสั่งให้ออกจากราชการ คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}",
+ SalaryRef = "คำสั่งให้ออกจากราชการ คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}",
OcId = lastSarary.OcId,
@@ -4644,14 +4981,14 @@ namespace BMA.EHR.Application.Repositories.Commands
// TODO: ต้องเปลี่ยนเป็น Email จริงนะ ตอนนี้ Hardcode อยู่
// Send noti inbox and email
- var subject = $"คุณได้รับคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}";
+ 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} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
+ Subject = $"คุณได้รับคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
Body = $"คุณได้รับคำสั่งให้ออกจากราชการ เลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
ReceiverUserId = data.Profile.Id,
Payload = "",
@@ -4759,7 +5096,7 @@ namespace BMA.EHR.Application.Repositories.Commands
PositionSalaryAmount = lastSarary.PositionSalaryAmount,
MouthSalaryAmount = lastSarary.MouthSalaryAmount,
SalaryClass = "",
- SalaryRef = "คำสั่งปลดออกจากราชการ คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}",
+ SalaryRef = "คำสั่งปลดออกจากราชการ คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}",
OcId = lastSarary.OcId,
@@ -4807,14 +5144,14 @@ namespace BMA.EHR.Application.Repositories.Commands
// TODO: ต้องเปลี่ยนเป็น Email จริงนะ ตอนนี้ Hardcode อยู่
// Send noti inbox and email
- var subject = $"คุณได้รับคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}";
+ 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} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
+ Subject = $"คุณได้รับคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
Body = $"คุณได้รับคำสั่งปลดออกจากราชการ เลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
ReceiverUserId = data.Profile.Id,
Payload = "",
@@ -4922,7 +5259,7 @@ namespace BMA.EHR.Application.Repositories.Commands
PositionSalaryAmount = lastSarary.PositionSalaryAmount,
MouthSalaryAmount = lastSarary.MouthSalaryAmount,
SalaryClass = "",
- SalaryRef = "คำสั่งไล่ออกจากราชการ คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}",
+ SalaryRef = "คำสั่งไล่ออกจากราชการ คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}",
OcId = lastSarary.OcId,
@@ -4970,14 +5307,14 @@ namespace BMA.EHR.Application.Repositories.Commands
// TODO: ต้องเปลี่ยนเป็น Email จริงนะ ตอนนี้ Hardcode อยู่
// Send noti inbox and email
- var subject = $"คุณได้รับคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}";
+ 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} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
+ Subject = $"คุณได้รับคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
Body = $"คุณได้รับคำสั่งไล่ออกจากราชการ เลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
ReceiverUserId = data.Profile.Id,
Payload = "",
@@ -5046,6 +5383,166 @@ namespace BMA.EHR.Application.Repositories.Commands
}
}
+ ///
+ /// C-PM-21 - คำสั่งแต่งตั้งลูกจ้างชั่วคราวเป็นลูกจ้างประจำ
+ ///
+ /// object ของรายการคำสั่ง
+ ///
+ private async Task ExecuteCommand21Async(Command command)
+ {
+ try
+ {
+ foreach (var recv in command.Receivers)
+ {
+ var data = await _dbContext.Set()
+ .Include(x => x.Profile)
+ .ThenInclude(x => x.Salaries)
+ .ThenInclude(x => x.PositionLevel)
+
+ .FirstOrDefaultAsync(x => x.Id == recv.RefPlacementProfileId);
+
+ if (data == null)
+ throw new Exception(GlobalMessages.DataNotFound);
+
+ data.Profile.EmployeeClass = "perm"; // ลจ ประจำ
+
+ var lastSarary = data.Profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault();
+ var order = 1;
+ if (lastSarary.Order != null)
+ order = lastSarary.Order.Value + 1;
+
+ var salary = new ProfileSalary
+ {
+ Order = order,
+ Date = command.CommandAffectDate,
+ Amount = lastSarary.Amount,
+ PositionSalaryAmount = lastSarary.PositionSalaryAmount,
+ MouthSalaryAmount = lastSarary.MouthSalaryAmount,
+ SalaryClass = "",
+ SalaryRef = "คำสั่งแต่งตั้งลูกจ้างชั่วคราวเป็นลูกจ้างประจำ คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}",
+
+ OcId = lastSarary.OcId,
+
+
+ PositionLevel = lastSarary.PositionLevel,
+ PositionLineId = lastSarary.PositionLineId,
+ PositionTypeId = lastSarary.PositionTypeId,
+ OrganizationShortNameId = lastSarary.OrganizationShortNameId,
+ PosNoId = lastSarary.PosNoId,
+
+ CommandNo = $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()}",
+ CommandTypeName = command.CommandType.Name,
+
+
+ PositionEmployeeGroupId = null,
+ PositionEmployeeLevelId = null,
+ PositionEmployeePositionId = null,
+ PositionEmployeePositionSideId = null,
+ PosNoEmployee = "",
+
+
+ //PositionPathSideId = lastSarary.PositionPathSideId == null,
+ PositionExecutiveId = lastSarary.PositionExecutiveId,
+ //PositionExecutiveSideId = lastSarary.PositionExecutiveSideId,
+
+ IsActive = true,
+ CreatedAt = DateTime.Now,
+ CreatedFullName = FullName ?? "System Administrator",
+ CreatedUserId = UserId ?? "",
+ LastUpdatedAt = DateTime.Now,
+ LastUpdateFullName = FullName ?? "System Administrator",
+ LastUpdateUserId = UserId ?? "",
+
+ };
+
+ if (lastSarary.PositionPathSideId != null) salary.PositionPathSideId = lastSarary.PositionPathSideId;
+ if (lastSarary.PositionExecutiveSideId != null) salary.PositionExecutiveSideId = lastSarary.PositionExecutiveSideId;
+
+ data.Profile.Salaries.Add(salary);
+
+ // update placementstatus
+ data.Status = "DONE";
+
+ 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");
+
+
+ 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 = data.Profile.Id,
+ Payload = "",
+ };
+ _dbContext.Set().Add(inbox);
+
+ var noti = new Notification
+ {
+ Body = $"คุณได้รับคำสั่งแต่งตั้งลูกจ้างชั่วคราวเป็นลูกจ้างประจำ เลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
+ ReceiverUserId = data.Profile.Id,
+ Type = "",
+ Payload = "",
+ };
+ _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 = "",
+ };
+ _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");
+ }
+
+
+ var noti = new Notification
+ {
+ Body = $"คำสั่งแต่งตั้งลูกจ้างชั่วคราวเป็นลูกจ้างประจำ คำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
+ ReceiverUserId = pf.Id,
+ Type = "",
+ Payload = "",
+ };
+ _dbContext.Set().Add(noti);
+ }
+ }
+
+ // change command status
+ var cmdStatus = await _dbContext.Set().FirstOrDefaultAsync(x => x.Sequence == 5);
+ command.CommandStatusId = cmdStatus!.Id;
+
+ await _dbContext.SaveChangesAsync();
+ }
+ catch
+ {
+ throw;
+ }
+ }
+
#endregion
#endregion