จัดการข้อมูล ProfilePosition

This commit is contained in:
Suphonchai Phoonsawat 2023-10-12 05:43:22 +07:00
parent 330ec22405
commit af31fcd8b4

View file

@ -2265,6 +2265,28 @@ namespace BMA.EHR.Application.Repositories.Commands
profile.Salaries.Add(salary);
// change profile position
var profilePosition = await _dbContext.Set<ProfilePosition>()
.Include(x => x.Profile)
.Include(x => x.OrganizationPosition)
.FirstOrDefaultAsync(x => x.Profile!.Id == profile.Id);
if (profilePosition == null)
{
profilePosition = new ProfilePosition
{
Profile = profile,
OrganizationPosition = placementProfile.OrganizationPosition,
IsActive = true,
IsPublished = true,
};
_dbContext.Set<ProfilePosition>().Add(profilePosition);
}
else
{
profilePosition.OrganizationPosition = placementProfile.OrganizationPosition;
//_dbContext.Attatch(profilePosition);
}
// update placementstatus
placementProfile.PlacementStatus = "CONTAIN";
@ -2518,6 +2540,28 @@ namespace BMA.EHR.Application.Repositories.Commands
profile.Salaries.Add(salary);
// change profile position
var profilePosition = await _dbContext.Set<ProfilePosition>()
.Include(x => x.Profile)
.Include(x => x.OrganizationPosition)
.FirstOrDefaultAsync(x => x.Profile!.Id == profile.Id);
if (profilePosition == null)
{
profilePosition = new ProfilePosition
{
Profile = profile,
OrganizationPosition = placementProfile.OrganizationPosition,
IsActive = true,
IsPublished = true,
};
_dbContext.Set<ProfilePosition>().Add(profilePosition);
}
else
{
profilePosition.OrganizationPosition = placementProfile.OrganizationPosition;
//_dbContext.Attatch(profilePosition);
}
// update placementstatus
placementProfile.PlacementStatus = "CONTAIN";
@ -2748,6 +2792,28 @@ namespace BMA.EHR.Application.Repositories.Commands
profile.Salaries.Add(salary);
// change profile position
var profilePosition = await _dbContext.Set<ProfilePosition>()
.Include(x => x.Profile)
.Include(x => x.OrganizationPosition)
.FirstOrDefaultAsync(x => x.Profile!.Id == profile.Id);
if (profilePosition == null)
{
profilePosition = new ProfilePosition
{
Profile = profile,
OrganizationPosition = placementProfile.OrganizationPosition,
IsActive = true,
IsPublished = true,
};
_dbContext.Set<ProfilePosition>().Add(profilePosition);
}
else
{
profilePosition.OrganizationPosition = placementProfile.OrganizationPosition;
//_dbContext.Attatch(profilePosition);
}
// update placementstatus
placementProfile.Status = "DONE";
@ -2978,6 +3044,28 @@ namespace BMA.EHR.Application.Repositories.Commands
profile.Salaries.Add(salary);
// change profile position
var profilePosition = await _dbContext.Set<ProfilePosition>()
.Include(x => x.Profile)
.Include(x => x.OrganizationPosition)
.FirstOrDefaultAsync(x => x.Profile!.Id == profile.Id);
if (profilePosition == null)
{
profilePosition = new ProfilePosition
{
Profile = profile,
OrganizationPosition = placementProfile.OrganizationPosition,
IsActive = true,
IsPublished = true,
};
_dbContext.Set<ProfilePosition>().Add(profilePosition);
}
else
{
profilePosition.OrganizationPosition = placementProfile.OrganizationPosition;
//_dbContext.Attatch(profilePosition);
}
// update placementstatus
placementProfile.Status = "DONE";
@ -3208,6 +3296,28 @@ namespace BMA.EHR.Application.Repositories.Commands
profile.Salaries.Add(salary);
// change profile position
var profilePosition = await _dbContext.Set<ProfilePosition>()
.Include(x => x.Profile)
.Include(x => x.OrganizationPosition)
.FirstOrDefaultAsync(x => x.Profile!.Id == profile.Id);
if (profilePosition == null)
{
profilePosition = new ProfilePosition
{
Profile = profile,
OrganizationPosition = placementProfile.OrganizationPosition,
IsActive = true,
IsPublished = true,
};
_dbContext.Set<ProfilePosition>().Add(profilePosition);
}
else
{
profilePosition.OrganizationPosition = placementProfile.OrganizationPosition;
//_dbContext.Attatch(profilePosition);
}
// update placementstatus
placementProfile.Status = "DONE";
@ -3446,6 +3556,16 @@ namespace BMA.EHR.Application.Repositories.Commands
profile.Salaries.Add(salary);
// add profile position
var profilePosition = new ProfilePosition
{
Profile = profile,
OrganizationPosition = placementProfile.OrganizationPosition,
IsActive = true,
IsPublished = true,
};
_dbContext.Set<ProfilePosition>().Add(profilePosition);
// update placementstatus
placementProfile.Status = "DONE";
@ -3693,6 +3813,16 @@ namespace BMA.EHR.Application.Repositories.Commands
profile.Salaries.Add(salary);
// add profile position
var profilePosition = new ProfilePosition
{
Profile = profile,
OrganizationPosition = placementProfile.OrganizationPosition,
IsActive = true,
IsPublished = true,
};
_dbContext.Set<ProfilePosition>().Add(profilePosition);
// update placementstatus
placementProfile.Status = "DONE";
@ -4219,6 +4349,14 @@ namespace BMA.EHR.Application.Repositories.Commands
data.Salaries.Add(salary);
// remove profile position
var profilePosition = await _dbContext.Set<ProfilePosition>()
.Include(x => x.Profile)
.Include(x => x.OrganizationPosition)
.FirstOrDefaultAsync(x => x.Profile!.Id == data.Id);
if (profilePosition != null)
_dbContext.Set<ProfilePosition>().Remove(profilePosition);
// update placementstatus
//data.Status = "DONE";
@ -4399,6 +4537,14 @@ namespace BMA.EHR.Application.Repositories.Commands
data.Profile.Salaries.Add(salary);
// remove profile position
var profilePosition = await _dbContext.Set<ProfilePosition>()
.Include(x => x.Profile)
.Include(x => x.OrganizationPosition)
.FirstOrDefaultAsync(x => x.Profile!.Id == data.Id);
if (profilePosition != null)
_dbContext.Set<ProfilePosition>().Remove(profilePosition);
// update placementstatus
//data.Status = "DONE";
@ -4483,7 +4629,7 @@ namespace BMA.EHR.Application.Repositories.Commands
}
/// <summary>
/// C-PM-14 - คำสั่งให้โอนข้าราชการกรุงเทพมหานครสามัญ
/// C-PM-14 - คำสั่งรับโอนข้าราชการกรุงเทพมหานครสามัญ
/// </summary>
/// <param name="command">object ของรายการคำสั่ง</param>
/// <returns></returns>
@ -5286,6 +5432,14 @@ namespace BMA.EHR.Application.Repositories.Commands
data.Profile.Salaries.Add(salary);
// remove profile position
var profilePosition = await _dbContext.Set<ProfilePosition>()
.Include(x => x.Profile)
.Include(x => x.OrganizationPosition)
.FirstOrDefaultAsync(x => x.Profile!.Id == data.Profile.Id);
if (profilePosition != null)
_dbContext.Set<ProfilePosition>().Remove(profilePosition);
// update placementstatus
data.Status = "DONE";
@ -5466,6 +5620,14 @@ namespace BMA.EHR.Application.Repositories.Commands
data.Profile.Salaries.Add(salary);
// remove profile position
var profilePosition = await _dbContext.Set<ProfilePosition>()
.Include(x => x.Profile)
.Include(x => x.OrganizationPosition)
.FirstOrDefaultAsync(x => x.Profile!.Id == data.Profile.Id);
if (profilePosition != null)
_dbContext.Set<ProfilePosition>().Remove(profilePosition);
// update placementstatus
data.Status = "DONE";
@ -5550,7 +5712,7 @@ namespace BMA.EHR.Application.Repositories.Commands
}
/// <summary>
/// C-PM-19 - คำสั่งให้ออกจากราชการ
/// C-PM-19 - คำสั่งปลดออกจากราชการ
/// </summary>
/// <param name="command">object ของรายการคำสั่ง</param>
/// <returns></returns>
@ -5646,6 +5808,14 @@ namespace BMA.EHR.Application.Repositories.Commands
data.Profile.Salaries.Add(salary);
// remove profile position
var profilePosition = await _dbContext.Set<ProfilePosition>()
.Include(x => x.Profile)
.Include(x => x.OrganizationPosition)
.FirstOrDefaultAsync(x => x.Profile!.Id == data.Profile.Id);
if (profilePosition != null)
_dbContext.Set<ProfilePosition>().Remove(profilePosition);
// update placementstatus
data.Status = "DONE";
@ -5730,7 +5900,7 @@ namespace BMA.EHR.Application.Repositories.Commands
}
/// <summary>
/// C-PM-20 - คำสั่งให้ออกจากราชการ
/// C-PM-20 - คำสั่งไล่ออกจากราชการ
/// </summary>
/// <param name="command">object ของรายการคำสั่ง</param>
/// <returns></returns>
@ -5826,6 +5996,14 @@ namespace BMA.EHR.Application.Repositories.Commands
data.Profile.Salaries.Add(salary);
// remove profile position
var profilePosition = await _dbContext.Set<ProfilePosition>()
.Include(x => x.Profile)
.Include(x => x.OrganizationPosition)
.FirstOrDefaultAsync(x => x.Profile!.Id == data.Profile.Id);
if (profilePosition != null)
_dbContext.Set<ProfilePosition>().Remove(profilePosition);
// update placementstatus
data.Status = "DONE";