From 5464189e6e9a9320823456d402888a571f420b27 Mon Sep 17 00:00:00 2001 From: Suphonchai Phoonsawat Date: Thu, 12 Oct 2023 05:43:22 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=88=E0=B8=B1=E0=B8=94=E0=B8=81=E0=B8=B2?= =?UTF-8?q?=E0=B8=A3=E0=B8=82=E0=B9=89=E0=B8=AD=E0=B8=A1=E0=B8=B9=E0=B8=A5?= =?UTF-8?q?=20ProfilePosition?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Commands/CommandRepository.cs | 184 +++++++++++++++++- 1 file changed, 181 insertions(+), 3 deletions(-) diff --git a/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs b/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs index f9e95cbb..943455c3 100644 --- a/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs +++ b/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs @@ -2265,6 +2265,28 @@ namespace BMA.EHR.Application.Repositories.Commands profile.Salaries.Add(salary); + // change profile position + var profilePosition = await _dbContext.Set() + .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().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() + .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().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() + .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().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() + .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().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() + .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().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().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().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() + .Include(x => x.Profile) + .Include(x => x.OrganizationPosition) + .FirstOrDefaultAsync(x => x.Profile!.Id == data.Id); + if (profilePosition != null) + _dbContext.Set().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() + .Include(x => x.Profile) + .Include(x => x.OrganizationPosition) + .FirstOrDefaultAsync(x => x.Profile!.Id == data.Id); + if (profilePosition != null) + _dbContext.Set().Remove(profilePosition); + // update placementstatus //data.Status = "DONE"; @@ -4483,7 +4629,7 @@ namespace BMA.EHR.Application.Repositories.Commands } /// - /// C-PM-14 - คำสั่งให้โอนข้าราชการกรุงเทพมหานครสามัญ + /// C-PM-14 - คำสั่งรับโอนข้าราชการกรุงเทพมหานครสามัญ /// /// object ของรายการคำสั่ง /// @@ -5286,6 +5432,14 @@ namespace BMA.EHR.Application.Repositories.Commands data.Profile.Salaries.Add(salary); + // remove profile position + var profilePosition = await _dbContext.Set() + .Include(x => x.Profile) + .Include(x => x.OrganizationPosition) + .FirstOrDefaultAsync(x => x.Profile!.Id == data.Profile.Id); + if (profilePosition != null) + _dbContext.Set().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() + .Include(x => x.Profile) + .Include(x => x.OrganizationPosition) + .FirstOrDefaultAsync(x => x.Profile!.Id == data.Profile.Id); + if (profilePosition != null) + _dbContext.Set().Remove(profilePosition); + // update placementstatus data.Status = "DONE"; @@ -5550,7 +5712,7 @@ namespace BMA.EHR.Application.Repositories.Commands } /// - /// C-PM-19 - คำสั่งให้ออกจากราชการ + /// C-PM-19 - คำสั่งปลดออกจากราชการ /// /// object ของรายการคำสั่ง /// @@ -5646,6 +5808,14 @@ namespace BMA.EHR.Application.Repositories.Commands data.Profile.Salaries.Add(salary); + // remove profile position + var profilePosition = await _dbContext.Set() + .Include(x => x.Profile) + .Include(x => x.OrganizationPosition) + .FirstOrDefaultAsync(x => x.Profile!.Id == data.Profile.Id); + if (profilePosition != null) + _dbContext.Set().Remove(profilePosition); + // update placementstatus data.Status = "DONE"; @@ -5730,7 +5900,7 @@ namespace BMA.EHR.Application.Repositories.Commands } /// - /// C-PM-20 - คำสั่งให้ออกจากราชการ + /// C-PM-20 - คำสั่งไล่ออกจากราชการ /// /// object ของรายการคำสั่ง /// @@ -5826,6 +5996,14 @@ namespace BMA.EHR.Application.Repositories.Commands data.Profile.Salaries.Add(salary); + // remove profile position + var profilePosition = await _dbContext.Set() + .Include(x => x.Profile) + .Include(x => x.OrganizationPosition) + .FirstOrDefaultAsync(x => x.Profile!.Id == data.Profile.Id); + if (profilePosition != null) + _dbContext.Set().Remove(profilePosition); + // update placementstatus data.Status = "DONE";