diff --git a/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs b/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs index 69c99f0c..fa489c66 100644 --- a/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs +++ b/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs @@ -9,6 +9,7 @@ using BMA.EHR.Domain.Models.MetaData; using BMA.EHR.Domain.Models.Notifications; using BMA.EHR.Domain.Models.Organizations; using BMA.EHR.Domain.Models.Placement; +using BMA.EHR.Domain.Models.Retirement; using BMA.EHR.Domain.Shared; using Microsoft.AspNetCore.Http; using Microsoft.EntityFrameworkCore; @@ -82,6 +83,45 @@ namespace BMA.EHR.Application.Repositories.Commands case "C-PM-04": result = await GetReceiver04Async(command); break; + case "C-PM-05": + result = await GetReceiver05Async(command); + break; + case "C-PM-06": + result = await GetReceiver06Async(command); + break; + case "C-PM-07": + result = await GetReceiver07Async(command); + break; + case "C-PM-08": + result = await GetReceiver08Async(command); + break; + case "C-PM-09": + result = await GetReceiver09Async(command); + break; + case "C-PM-13": + result = await GetReceiver13Async(command); + break; + case "C-PM-14": + result = await GetReceiver14Async(command); + break; + case "C-PM-15": + result = await GetReceiver15Async(command); + break; + case "C-PM-16": + result = await GetReceiver16Async(command); + break; + case "C-PM-17": + result = await GetReceiver17Async(command); + break; + case "C-PM-18": + result = await GetReceiver18Async(command); + break; + case "C-PM-19": + result = await GetReceiver19Async(command); + break; + case "C-PM-20": + result = await GetReceiver20Async(command); + break; default: throw new Exception(GlobalMessages.MethodForCommandTypeNotImplement); } @@ -299,7 +339,7 @@ namespace BMA.EHR.Application.Repositories.Commands var otherCommandReceivers = await _dbContext.Set() .Include(x => x.Command) .ThenInclude(x => x.CommandType) - .Where(x => x.Command.CommandType.CommandCode.Trim().ToUpper() == "C-PM-03") + .Where(x => x.Command.CommandType.CommandCode.Trim().ToUpper() == "C-PM-04") .Where(x => x.Command.Id != command.Id) .Select(x => x.CitizenId) .ToListAsync(); @@ -349,6 +389,761 @@ namespace BMA.EHR.Application.Repositories.Commands } } + /// + /// C-PM-05 - คำสั่งแต่งตั้ง + /// + /// object ของรายการคำสั่ง + /// + private async Task> GetReceiver05Async(Command command) + { + try + { + var result = new List(); + // TODO : ต้องมา list คนตามประเภทอีกครั้งนึง + + // 1. หารายชื่อที่ถูกเลือกไปแล้ว ในประเภทเดียวกัน + var otherCommandReceivers = await _dbContext.Set() + .Include(x => x.Command) + .ThenInclude(x => x.CommandType) + .Where(x => x.Command.CommandType.CommandCode.Trim().ToUpper() == "C-PM-05") + .Where(x => x.Command.Id != command.Id) + .Select(x => x.CitizenId) + .ToListAsync(); + + // 2. Query + var appointPeople = await _dbContext.Set() + .Include(x => x.CommandType) + .Include(x => x.Prefix) + .Include(x => x.OrganizationPosition) + .ThenInclude(x => x!.Organization) + //.Where(x => x.OrganizationPosition!.Organization!.Id == command.OwnerGovId) + .Where(x => !otherCommandReceivers.Contains(x.CitizenId!)) + .Where(x => x.Status.Trim().ToUpper() == "REPORT") + .Where(x => x.CommandType!.Id == command.CommandType!.Id) + .OrderBy(x => x.CitizenId) + .ToListAsync(); + + // 3. Create new Record + var seq = 1; + foreach (var item in appointPeople) + { + var receiver = new CommandReceiver + { + Sequence = seq, + CitizenId = item.CitizenId!, + Prefix = item.Prefix!.Name, + FirstName = item.Firstname!, + LastName = item.Lastname!, + RefPlacementProfileId = item.Id + }; + seq++; + + result.Add(receiver); + } + + return result; + } + catch + { + throw; + } + } + + /// + /// C-PM-06 - คำสั่งเลื่อน + /// + /// object ของรายการคำสั่ง + /// + private async Task> GetReceiver06Async(Command command) + { + try + { + var result = new List(); + // TODO : ต้องมา list คนตามประเภทอีกครั้งนึง + + // 1. หารายชื่อที่ถูกเลือกไปแล้ว ในประเภทเดียวกัน + var otherCommandReceivers = await _dbContext.Set() + .Include(x => x.Command) + .ThenInclude(x => x.CommandType) + .Where(x => x.Command.CommandType.CommandCode.Trim().ToUpper() == "C-PM-06") + .Where(x => x.Command.Id != command.Id) + .Select(x => x.CitizenId) + .ToListAsync(); + + // 2. Query + var appointPeople = await _dbContext.Set() + .Include(x => x.CommandType) + .Include(x => x.Prefix) + .Include(x => x.OrganizationPosition) + .ThenInclude(x => x!.Organization) + //.Where(x => x.OrganizationPosition!.Organization!.Id == command.OwnerGovId) + .Where(x => !otherCommandReceivers.Contains(x.CitizenId!)) + .Where(x => x.Status.Trim().ToUpper() == "REPORT") + .Where(x => x.CommandType!.Id == command.CommandType!.Id) + .OrderBy(x => x.CitizenId) + .ToListAsync(); + + // 3. Create new Record + var seq = 1; + foreach (var item in appointPeople) + { + var receiver = new CommandReceiver + { + Sequence = seq, + CitizenId = item.CitizenId!, + Prefix = item.Prefix!.Name, + FirstName = item.Firstname!, + LastName = item.Lastname!, + RefPlacementProfileId = item.Id + }; + seq++; + + result.Add(receiver); + } + + return result; + } + catch + { + throw; + } + } + + /// + /// C-PM-07 - คำสั่งย้าย + /// + /// object ของรายการคำสั่ง + /// + private async Task> GetReceiver07Async(Command command) + { + try + { + var result = new List(); + // TODO : ต้องมา list คนตามประเภทอีกครั้งนึง + + // 1. หารายชื่อที่ถูกเลือกไปแล้ว ในประเภทเดียวกัน + var otherCommandReceivers = await _dbContext.Set() + .Include(x => x.Command) + .ThenInclude(x => x.CommandType) + .Where(x => x.Command.CommandType.CommandCode.Trim().ToUpper() == "C-PM-07") + .Where(x => x.Command.Id != command.Id) + .Select(x => x.CitizenId) + .ToListAsync(); + + // 2. Query + var appointPeople = await _dbContext.Set() + .Include(x => x.Prefix) + .Include(x => x.OrganizationPosition) + .ThenInclude(x => x!.Organization) + //.Where(x => x.OrganizationPosition!.Organization!.Id == command.OwnerGovId) + .Where(x => !otherCommandReceivers.Contains(x.CitizenId!)) + .Where(x => x.Status.Trim().ToUpper() == "REPORT") + .OrderBy(x => x.CitizenId) + .ToListAsync(); + + // 3. Create new Record + var seq = 1; + foreach (var item in appointPeople) + { + var receiver = new CommandReceiver + { + Sequence = seq, + CitizenId = item.CitizenId!, + Prefix = item.Prefix!.Name, + FirstName = item.Firstname!, + LastName = item.Lastname!, + RefPlacementProfileId = item.Id + }; + seq++; + + result.Add(receiver); + } + + return result; + } + catch + { + throw; + } + } + + /// + /// C-PM-08 - คำสั่งบรรจุและแต่งตั้งข้าราชการฯ กลับเข้ารับราชการ + /// + /// object ของรายการคำสั่ง + /// + private async Task> GetReceiver08Async(Command command) + { + try + { + var result = new List(); + // TODO : ต้องมา list คนตามประเภทอีกครั้งนึง + + // 1. หารายชื่อที่ถูกเลือกไปแล้ว ในประเภทเดียวกัน + var otherCommandReceivers = await _dbContext.Set() + .Include(x => x.Command) + .ThenInclude(x => x.CommandType) + .Where(x => x.Command.CommandType.CommandCode.Trim().ToUpper() == "C-PM-08") + .Where(x => x.Command.Id != command.Id) + .Select(x => x.CitizenId) + .ToListAsync(); + + // 2. Query + var appointPeople = await _dbContext.Set() + .Include(x => x.CommandType) + .Include(x => x.Prefix) + .Include(x => x.OrganizationPosition) + .ThenInclude(x => x!.Organization) + //.Where(x => x.OrganizationPosition!.Organization!.Id == command.OwnerGovId) + .Where(x => !otherCommandReceivers.Contains(x.CitizenId!)) + .Where(x => x.Status.Trim().ToUpper() == "REPORT") + .Where(x => x.CommandType!.Id == command.CommandType!.Id) + .OrderBy(x => x.CitizenId) + .ToListAsync(); + + // 3. Create new Record + var seq = 1; + foreach (var item in appointPeople) + { + var receiver = new CommandReceiver + { + Sequence = seq, + CitizenId = item.CitizenId!, + Prefix = item.Prefix!.Name, + FirstName = item.Firstname!, + LastName = item.Lastname!, + RefPlacementProfileId = item.Id + }; + seq++; + + result.Add(receiver); + } + + return result; + } + catch + { + throw; + } + } + + /// + /// C-PM-09 - คำสั่งบรรจุและแต่งตั้งผู้ออกไปรับราชการทหารกลับเข้ารับราชการ + /// + /// object ของรายการคำสั่ง + /// + private async Task> GetReceiver09Async(Command command) + { + try + { + var result = new List(); + // TODO : ต้องมา list คนตามประเภทอีกครั้งนึง + + // 1. หารายชื่อที่ถูกเลือกไปแล้ว ในประเภทเดียวกัน + var otherCommandReceivers = await _dbContext.Set() + .Include(x => x.Command) + .ThenInclude(x => x.CommandType) + .Where(x => x.Command.CommandType.CommandCode.Trim().ToUpper() == "C-PM-09") + .Where(x => x.Command.Id != command.Id) + .Select(x => x.CitizenId) + .ToListAsync(); + + // 2. Query + var appointPeople = await _dbContext.Set() + .Include(x => x.CommandType) + .Include(x => x.Prefix) + .Include(x => x.OrganizationPosition) + .ThenInclude(x => x!.Organization) + //.Where(x => x.OrganizationPosition!.Organization!.Id == command.OwnerGovId) + .Where(x => !otherCommandReceivers.Contains(x.CitizenId!)) + .Where(x => x.Status.Trim().ToUpper() == "REPORT") + .Where(x => x.CommandType!.Id == command.CommandType!.Id) + .OrderBy(x => x.CitizenId) + .ToListAsync(); + + // 3. Create new Record + var seq = 1; + foreach (var item in appointPeople) + { + var receiver = new CommandReceiver + { + Sequence = seq, + CitizenId = item.CitizenId!, + Prefix = item.Prefix!.Name, + FirstName = item.Firstname!, + LastName = item.Lastname!, + RefPlacementProfileId = item.Id + }; + seq++; + + result.Add(receiver); + } + + return result; + } + catch + { + throw; + } + } + + /// + /// C-PM-13 - คำสั่งให้โอนข้าราชการกรุงเทพมหานครสามัญ + /// + /// object ของรายการคำสั่ง + /// + private async Task> GetReceiver13Async(Command command) + { + try + { + var result = new List(); + // TODO : ต้องมา list คนตามประเภทอีกครั้งนึง + + // 1. หารายชื่อที่ถูกเลือกไปแล้ว ในประเภทเดียวกัน + var otherCommandReceivers = await _dbContext.Set() + .Include(x => x.Command) + .ThenInclude(x => x.CommandType) + .Where(x => x.Command.CommandType.CommandCode.Trim().ToUpper() == "C-PM-13") + .Where(x => x.Command.Id != command.Id) + .Select(x => x.CitizenId) + .ToListAsync(); + + // 2. Query + var appointPeople = await _dbContext.Set() + .Include(x => x.Profile) + .ThenInclude(x => x.Prefix) + //.Where(x => x.OrganizationPosition!.Organization!.Id == command.OwnerGovId) + .Where(x => !otherCommandReceivers.Contains(x.Profile!.CitizenId!)) + .Where(x => x.Status.Trim().ToUpper() == "REPORT") + .OrderBy(x => x.Profile!.CitizenId) + .ToListAsync(); + + // 3. Create new Record + var seq = 1; + foreach (var item in appointPeople) + { + var receiver = new CommandReceiver + { + Sequence = seq, + CitizenId = item.Profile!.CitizenId!, + Prefix = item.Profile!.Prefix!.Name, + FirstName = item.Profile!.FirstName!, + LastName = item.Profile!.LastName!, + RefPlacementProfileId = item.Id + }; + seq++; + + result.Add(receiver); + } + + return result; + } + catch + { + throw; + } + } + + /// + /// C-PM-14 - คำสั่งรับโอนข้าราชการกรุงเทพมหานครสามัญ + /// + /// object ของรายการคำสั่ง + /// + private async Task> GetReceiver14Async(Command command) + { + try + { + var result = new List(); + // TODO : ต้องมา list คนตามประเภทอีกครั้งนึง + + // 1. หารายชื่อที่ถูกเลือกไปแล้ว ในประเภทเดียวกัน + var otherCommandReceivers = await _dbContext.Set() + .Include(x => x.Command) + .ThenInclude(x => x.CommandType) + .Where(x => x.Command.CommandType.CommandCode.Trim().ToUpper() == "C-PM-14") + .Where(x => x.Command.Id != command.Id) + .Select(x => x.CitizenId) + .ToListAsync(); + + // 2. Query + var appointPeople = await _dbContext.Set() + .Include(x => x.Prefix) + .Include(x => x.OrganizationPosition) + .ThenInclude(x => x!.Organization) + //.Where(x => x.OrganizationPosition!.Organization!.Id == command.OwnerGovId) + .Where(x => !otherCommandReceivers.Contains(x.CitizenId!)) + .Where(x => x.Status.Trim().ToUpper() == "REPORT") + .OrderBy(x => x.CitizenId) + .ToListAsync(); + + // 3. Create new Record + var seq = 1; + foreach (var item in appointPeople) + { + var receiver = new CommandReceiver + { + Sequence = seq, + CitizenId = item.CitizenId!, + Prefix = item.Prefix!.Name, + FirstName = item.Firstname!, + LastName = item.Lastname!, + RefPlacementProfileId = item.Id + }; + seq++; + + result.Add(receiver); + } + + return result; + } + catch + { + throw; + } + } + + /// + /// C-PM-15 - คำสั่งให้ช่วยราชการ + /// + /// object ของรายการคำสั่ง + /// + private async Task> GetReceiver15Async(Command command) + { + try + { + var result = new List(); + // TODO : ต้องมา list คนตามประเภทอีกครั้งนึง + + // 1. หารายชื่อที่ถูกเลือกไปแล้ว ในประเภทเดียวกัน + var otherCommandReceivers = await _dbContext.Set() + .Include(x => x.Command) + .ThenInclude(x => x.CommandType) + .Where(x => x.Command.CommandType.CommandCode.Trim().ToUpper() == "C-PM-15") + .Where(x => x.Command.Id != command.Id) + .Select(x => x.CitizenId) + .ToListAsync(); + + // 2. Query + var appointPeople = await _dbContext.Set() + .Include(x => x.Profile) + .ThenInclude(x => x.Prefix) + //.Where(x => x.OrganizationPosition!.Organization!.Id == command.OwnerGovId) + .Where(x => !otherCommandReceivers.Contains(x.Profile!.CitizenId!)) + .Where(x => x.Status.Trim().ToUpper() == "REPORT") + .OrderBy(x => x.Profile!.CitizenId) + .ToListAsync(); + + // 3. Create new Record + var seq = 1; + foreach (var item in appointPeople) + { + var receiver = new CommandReceiver + { + Sequence = seq, + CitizenId = item.Profile!.CitizenId!, + Prefix = item.Profile!.Prefix!.Name, + FirstName = item.Profile!.FirstName!, + LastName = item.Profile!.LastName!, + RefPlacementProfileId = item.Id + }; + seq++; + + result.Add(receiver); + } + + return result; + } + catch + { + throw; + } + } + + /// + /// C-PM-16 - คำสั่งส่งตัวกลับ + /// + /// object ของรายการคำสั่ง + /// + private async Task> GetReceiver16Async(Command command) + { + try + { + var result = new List(); + // TODO : ต้องมา list คนตามประเภทอีกครั้งนึง + + // 1. หารายชื่อที่ถูกเลือกไปแล้ว ในประเภทเดียวกัน + var otherCommandReceivers = await _dbContext.Set() + .Include(x => x.Command) + .ThenInclude(x => x.CommandType) + .Where(x => x.Command.CommandType.CommandCode.Trim().ToUpper() == "C-PM-16") + .Where(x => x.Command.Id != command.Id) + .Select(x => x.CitizenId) + .ToListAsync(); + + // 2. Query + var appointPeople = await _dbContext.Set() + .Include(x => x.Profile) + .ThenInclude(x => x.Prefix) + //.Where(x => x.OrganizationPosition!.Organization!.Id == command.OwnerGovId) + .Where(x => !otherCommandReceivers.Contains(x.Profile!.CitizenId!)) + .Where(x => x.Status.Trim().ToUpper() == "REPORT") + .OrderBy(x => x.Profile!.CitizenId) + .ToListAsync(); + + // 3. Create new Record + var seq = 1; + foreach (var item in appointPeople) + { + var receiver = new CommandReceiver + { + Sequence = seq, + CitizenId = item.Profile!.CitizenId!, + Prefix = item.Profile!.Prefix!.Name, + FirstName = item.Profile!.FirstName!, + LastName = item.Profile!.LastName!, + RefPlacementProfileId = item.Id + }; + seq++; + + result.Add(receiver); + } + + return result; + } + catch + { + throw; + } + } + + /// + /// C-PM-17 - คำสั่งอนุญาตให้ข้าราชการลาออกจากราชการ + /// + /// object ของรายการคำสั่ง + /// + private async Task> GetReceiver17Async(Command command) + { + try + { + var result = new List(); + // TODO : ต้องมา list คนตามประเภทอีกครั้งนึง + + // 1. หารายชื่อที่ถูกเลือกไปแล้ว ในประเภทเดียวกัน + var otherCommandReceivers = await _dbContext.Set() + .Include(x => x.Command) + .ThenInclude(x => x.CommandType) + .Where(x => x.Command.CommandType.CommandCode.Trim().ToUpper() == "C-PM-17") + .Where(x => x.Command.Id != command.Id) + .Select(x => x.CitizenId) + .ToListAsync(); + + // 2. Query + var appointPeople = await _dbContext.Set() + .Include(x => x.Profile) + .ThenInclude(x => x.Prefix) + //.Where(x => x.OrganizationPosition!.Organization!.Id == command.OwnerGovId) + .Where(x => !otherCommandReceivers.Contains(x.Profile!.CitizenId!)) + .Where(x => x.Status.Trim().ToUpper() == "REPORT") + .OrderBy(x => x.Profile!.CitizenId) + .ToListAsync(); + + // 3. Create new Record + var seq = 1; + foreach (var item in appointPeople) + { + var receiver = new CommandReceiver + { + Sequence = seq, + CitizenId = item.Profile!.CitizenId!, + Prefix = item.Profile!.Prefix!.Name, + FirstName = item.Profile!.FirstName!, + LastName = item.Profile!.LastName!, + RefPlacementProfileId = item.Id + }; + seq++; + + result.Add(receiver); + } + + return result; + } + catch + { + throw; + } + } + + /// + /// C-PM-18 - คำสั่งให้ออกจากราชการ + /// + /// object ของรายการคำสั่ง + /// + private async Task> GetReceiver18Async(Command command) + { + try + { + var result = new List(); + // TODO : ต้องมา list คนตามประเภทอีกครั้งนึง + + // 1. หารายชื่อที่ถูกเลือกไปแล้ว ในประเภทเดียวกัน + var otherCommandReceivers = await _dbContext.Set() + .Include(x => x.Command) + .ThenInclude(x => x.CommandType) + .Where(x => x.Command.CommandType.CommandCode.Trim().ToUpper() == "C-PM-18") + .Where(x => x.Command.Id != command.Id) + .Select(x => x.CitizenId) + .ToListAsync(); + + // 2. Query + var appointPeople = await _dbContext.Set() + .Include(x => x.Profile) + .ThenInclude(x => x.Prefix) + //.Where(x => x.OrganizationPosition!.Organization!.Id == command.OwnerGovId) + .Where(x => !otherCommandReceivers.Contains(x.Profile!.CitizenId!)) + .Where(x => x.Status.Trim().ToUpper() == "REPORT") + .OrderBy(x => x.Profile!.CitizenId) + .ToListAsync(); + + // 3. Create new Record + var seq = 1; + foreach (var item in appointPeople) + { + var receiver = new CommandReceiver + { + Sequence = seq, + CitizenId = item.Profile!.CitizenId!, + Prefix = item.Profile!.Prefix!.Name, + FirstName = item.Profile!.FirstName!, + LastName = item.Profile!.LastName!, + RefPlacementProfileId = item.Id + }; + seq++; + + result.Add(receiver); + } + + return result; + } + catch + { + throw; + } + } + + /// + /// C-PM-19 - คำสั่งปลดออกจากราชการ + /// + /// object ของรายการคำสั่ง + /// + private async Task> GetReceiver19Async(Command command) + { + try + { + var result = new List(); + // TODO : ต้องมา list คนตามประเภทอีกครั้งนึง + + // 1. หารายชื่อที่ถูกเลือกไปแล้ว ในประเภทเดียวกัน + var otherCommandReceivers = await _dbContext.Set() + .Include(x => x.Command) + .ThenInclude(x => x.CommandType) + .Where(x => x.Command.CommandType.CommandCode.Trim().ToUpper() == "C-PM-19") + .Where(x => x.Command.Id != command.Id) + .Select(x => x.CitizenId) + .ToListAsync(); + + // 2. Query + var appointPeople = await _dbContext.Set() + .Include(x => x.Profile) + .ThenInclude(x => x.Prefix) + //.Where(x => x.OrganizationPosition!.Organization!.Id == command.OwnerGovId) + .Where(x => !otherCommandReceivers.Contains(x.Profile!.CitizenId!)) + .Where(x => x.Status.Trim().ToUpper() == "REPORT") + .OrderBy(x => x.Profile!.CitizenId) + .ToListAsync(); + + // 3. Create new Record + var seq = 1; + foreach (var item in appointPeople) + { + var receiver = new CommandReceiver + { + Sequence = seq, + CitizenId = item.Profile!.CitizenId!, + Prefix = item.Profile!.Prefix!.Name, + FirstName = item.Profile!.FirstName!, + LastName = item.Profile!.LastName!, + RefPlacementProfileId = item.Id + }; + seq++; + + result.Add(receiver); + } + + return result; + } + catch + { + throw; + } + } + + /// + /// C-PM-20 - คำสั่งไล่ออกจากราชการ + /// + /// object ของรายการคำสั่ง + /// + private async Task> GetReceiver20Async(Command command) + { + try + { + var result = new List(); + // TODO : ต้องมา list คนตามประเภทอีกครั้งนึง + + // 1. หารายชื่อที่ถูกเลือกไปแล้ว ในประเภทเดียวกัน + var otherCommandReceivers = await _dbContext.Set() + .Include(x => x.Command) + .ThenInclude(x => x.CommandType) + .Where(x => x.Command.CommandType.CommandCode.Trim().ToUpper() == "C-PM-20") + .Where(x => x.Command.Id != command.Id) + .Select(x => x.CitizenId) + .ToListAsync(); + + // 2. Query + var appointPeople = await _dbContext.Set() + .Include(x => x.Profile) + .ThenInclude(x => x.Prefix) + //.Where(x => x.OrganizationPosition!.Organization!.Id == command.OwnerGovId) + .Where(x => !otherCommandReceivers.Contains(x.Profile!.CitizenId!)) + .Where(x => x.Status.Trim().ToUpper() == "REPORT") + .OrderBy(x => x.Profile!.CitizenId) + .ToListAsync(); + + // 3. Create new Record + var seq = 1; + foreach (var item in appointPeople) + { + var receiver = new CommandReceiver + { + Sequence = seq, + CitizenId = item.Profile!.CitizenId!, + Prefix = item.Profile!.Prefix!.Name, + FirstName = item.Profile!.FirstName!, + LastName = item.Profile!.LastName!, + RefPlacementProfileId = item.Id + }; + seq++; + + result.Add(receiver); + } + + return result; + } + catch + { + throw; + } + } + #endregion #region " Execute and Deploy "