protected static FR_Base Execute(DbConnection Connection, DbTransaction Transaction, P_L5TW_DTW_1325 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Base(); var item = new ORM_CMN_STR_Profession(); if (Parameter.CMN_STR_ProfessionID != Guid.Empty) { var result = item.Load(Connection, Transaction, Parameter.CMN_STR_ProfessionID); if (result.Status != FR_Status.Success || item.CMN_STR_ProfessionID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } item.IsDeleted = true; item.Save(Connection, Transaction); ORM_CMN_STR_ProfessionKey.Query professionKeyQuery = new ORM_CMN_STR_ProfessionKey.Query(); professionKeyQuery.CMN_STR_Profession_RefID = Parameter.CMN_STR_ProfessionID; professionKeyQuery.IsDeleted = false; professionKeyQuery.Tenant_RefID = securityTicket.TenantID; ORM_CMN_STR_ProfessionKey.Query.SoftDelete(Connection, Transaction, professionKeyQuery); return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L3P_SP_1653 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); if (Parameter.StaffTypeID == Guid.Empty) { ORM_CMN_STR_Profession profession = new ORM_CMN_STR_Profession(); profession.CMN_STR_ProfessionID = Guid.NewGuid(); profession.ProfessionName = Parameter.Name; profession.IsDeleted = false; profession.Tenant_RefID = securityTicket.TenantID; if (Parameter.IsLANRNeeded) { ORM_CMN_STR_ProfessionKey professionKey = new ORM_CMN_STR_ProfessionKey(); professionKey.CMN_STR_ProfessionKeyID = Guid.NewGuid(); professionKey.CMN_STR_Profession_RefID = profession.CMN_STR_ProfessionID; professionKey.SocialSecurityProfessionKey = Parameter.ProfessionKey; professionKey.IsDeleted = false; professionKey.Tenant_RefID = securityTicket.TenantID; professionKey.Save(Connection, Transaction); } if (Parameter.Skills != null) { foreach (var skillParam in Parameter.Skills) { ORM_CMN_STR_Skill_2_Profession skill2profession = new ORM_CMN_STR_Skill_2_Profession(); skill2profession.AssignmentID = Guid.NewGuid(); skill2profession.Profession_RefID = profession.CMN_STR_ProfessionID; skill2profession.Skill_RefID = skillParam.StaffSkillID; skill2profession.IsDeleted = skillParam.IsDeleted; skill2profession.Tenant_RefID = securityTicket.TenantID; skill2profession.Save(Connection, Transaction); } } profession.Save(Connection, Transaction); returnValue.Result = profession.CMN_STR_ProfessionID; } else { var profession = ORM_CMN_STR_Profession.Query.Search(Connection, Transaction, new ORM_CMN_STR_Profession.Query { CMN_STR_ProfessionID = Parameter.StaffTypeID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).SingleOrDefault(); if (Parameter.IsDeleted == false) { profession.ProfessionName = Parameter.Name; profession.IsDeleted = false; var professionKey = ORM_CMN_STR_ProfessionKey.Query.Search(Connection, Transaction, new ORM_CMN_STR_ProfessionKey.Query { SocialSecurityProfessionKey = Parameter.ProfessionKey, CMN_STR_Profession_RefID = Parameter.StaffTypeID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).SingleOrDefault(); if (professionKey != null) { if (Parameter.IsLANRNeeded) { professionKey.SocialSecurityProfessionKey = Parameter.ProfessionKey; } else { professionKey.IsDeleted = true; } professionKey.Save(Connection, Transaction); } else { if (Parameter.IsLANRNeeded) { professionKey = new ORM_CMN_STR_ProfessionKey(); professionKey.CMN_STR_ProfessionKeyID = Guid.NewGuid(); professionKey.CMN_STR_Profession_RefID = profession.CMN_STR_ProfessionID; professionKey.SocialSecurityProfessionKey = Parameter.ProfessionKey; professionKey.IsDeleted = false; professionKey.Tenant_RefID = securityTicket.TenantID; professionKey.Save(Connection, Transaction); } } if (Parameter.Skills != null) { foreach (var skillParam in Parameter.Skills) { var skillsFromParam = ORM_CMN_STR_Skill_2_Profession.Query.Search(Connection, Transaction, new ORM_CMN_STR_Skill_2_Profession.Query { Skill_RefID = skillParam.StaffSkillID, Profession_RefID = Parameter.StaffTypeID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).SingleOrDefault(); if (skillsFromParam == null) { ORM_CMN_STR_Skill_2_Profession skill2profession = new ORM_CMN_STR_Skill_2_Profession(); skill2profession.AssignmentID = Guid.NewGuid(); skill2profession.Profession_RefID = profession.CMN_STR_ProfessionID; skill2profession.Skill_RefID = skillParam.StaffSkillID; skill2profession.IsDeleted = skillParam.IsDeleted; skill2profession.Tenant_RefID = securityTicket.TenantID; skill2profession.Save(Connection, Transaction); } else { skillsFromParam.IsDeleted = skillParam.IsDeleted; skillsFromParam.Tenant_RefID = securityTicket.TenantID; skillsFromParam.Save(Connection, Transaction); } } } } else { var skillsForDelete = ORM_CMN_STR_Skill_2_Profession.Query.SoftDelete(Connection, Transaction, new ORM_CMN_STR_Skill_2_Profession.Query { Profession_RefID = Parameter.StaffTypeID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }); var professionKey = ORM_CMN_STR_ProfessionKey.Query.SoftDelete(Connection, Transaction, new ORM_CMN_STR_ProfessionKey.Query { SocialSecurityProfessionKey = Parameter.ProfessionKey, CMN_STR_Profession_RefID = Parameter.StaffTypeID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }); profession.IsDeleted = true; } profession.Save(Connection, Transaction); returnValue.Result = profession.CMN_STR_ProfessionID; } //Put your code here return(returnValue); #endregion UserCode }
protected static FR_L5TW_GTWFP_1326 Execute(DbConnection Connection, DbTransaction Transaction, P_L5TW_GTWFP_1326 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { //Leave UserCode region to enable user code saving #region UserCode var returnValue = new FR_L5TW_GTWFP_1326(); ORM_CMN_STR_Profession.Query professionQuery = new ORM_CMN_STR_Profession.Query(); professionQuery.CMN_STR_ProfessionID = Parameter.CMN_STR_ProfessionID; professionQuery.IsDeleted = false; professionQuery.Tenant_RefID = securityTicket.TenantID; List <ORM_CMN_STR_Profession> professions = ORM_CMN_STR_Profession.Query.Search(Connection, Transaction, professionQuery); if (professions != null && professions.Count != 0) { L5TW_GTWFT_1327 professionItem = new L5TW_GTWFT_1327(); ORM_CMN_STR_Profession profession = professions[0]; professionItem.CMN_STR_ProfessionID = profession.CMN_STR_ProfessionID; professionItem.ProfessionName = profession.ProfessionName; professionItem.GlobalPropertyMatchingID = profession.GlobalPropertyMatchingID; ORM_CMN_STR_ProfessionKey.Query professionKeyQuery = new ORM_CMN_STR_ProfessionKey.Query(); professionKeyQuery.CMN_STR_Profession_RefID = Parameter.CMN_STR_ProfessionID; professionKeyQuery.IsDeleted = false; professionKeyQuery.Tenant_RefID = securityTicket.TenantID; List <ORM_CMN_STR_ProfessionKey> professionKeys = ORM_CMN_STR_ProfessionKey.Query.Search(Connection, Transaction, professionKeyQuery); if (professionKeys.Count != 0) { ORM_CMN_STR_ProfessionKey professionKey = professionKeys[0]; professionItem.SocialSecurityProfessionKey = professionKey.SocialSecurityProfessionKey; ORM_CMN_EconomicRegion.Query economicRegionQuery = new ORM_CMN_EconomicRegion.Query(); economicRegionQuery.CMN_EconomicRegionID = professionKey.CMN_EconomicRegion_RefID; economicRegionQuery.IsDeleted = false; economicRegionQuery.Tenant_RefID = securityTicket.TenantID; List <ORM_CMN_EconomicRegion> economicRegions = ORM_CMN_EconomicRegion.Query.Search(Connection, Transaction, economicRegionQuery); if (economicRegions.Count != 0) { ORM_CMN_EconomicRegion economicRegion = economicRegions[0]; ORM_CMN_Country_2_EconomicRegion.Query economicRegionToCountryQuery = new ORM_CMN_Country_2_EconomicRegion.Query(); economicRegionToCountryQuery.CMN_EconomicRegion_RefID = economicRegion.CMN_EconomicRegionID; economicRegionToCountryQuery.IsDeleted = false; economicRegionToCountryQuery.Tenant_RefID = securityTicket.TenantID; List <ORM_CMN_Country_2_EconomicRegion> economicRegionToCountries = ORM_CMN_Country_2_EconomicRegion.Query.Search(Connection, Transaction, economicRegionToCountryQuery); if (economicRegionToCountries.Count != 0) { ORM_CMN_Country_2_EconomicRegion economicRegionToCountry = economicRegionToCountries[0]; ORM_CMN_Country.Query countryQuery = new ORM_CMN_Country.Query(); countryQuery.CMN_CountryID = economicRegionToCountry.CMN_Country_RefID; countryQuery.IsDeleted = false; countryQuery.Tenant_RefID = securityTicket.TenantID; List <ORM_CMN_Country> countries = ORM_CMN_Country.Query.Search(Connection, Transaction, countryQuery); if (countries.Count != 0) { professionItem.Country_ISOCode_Alpha2 = countries[0].Country_ISOCode_Alpha2; } } } } returnValue.Result = new L5TW_GTWFP_1326(); returnValue.Result.TypeOfWork = professionItem; } //Put your code here return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5TW_STW_1325 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); var item = new ORM_CMN_STR_Profession(); if (Parameter.CMN_STR_ProfessionID != Guid.Empty) { var result = item.Load(Connection, Transaction, Parameter.CMN_STR_ProfessionID); if (result.Status != FR_Status.Success || item.CMN_STR_ProfessionID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } item.GlobalPropertyMatchingID = Parameter.GlobalPropertyMatchingID; item.ProfessionName = Parameter.ProfessionName; item.Tenant_RefID = securityTicket.TenantID; item.Save(Connection, Transaction); ORM_CMN_STR_ProfessionKey.Query professionKeyQuery = new ORM_CMN_STR_ProfessionKey.Query(); professionKeyQuery.CMN_STR_Profession_RefID = item.CMN_STR_ProfessionID; professionKeyQuery.IsDeleted = false; professionKeyQuery.Tenant_RefID = securityTicket.TenantID; List <ORM_CMN_STR_ProfessionKey> professionKeys = ORM_CMN_STR_ProfessionKey.Query.Search(Connection, Transaction, professionKeyQuery); if (professionKeys.Count != 0) { ORM_CMN_STR_ProfessionKey professionKey = professionKeys[0]; professionKey.SocialSecurityProfessionKey = Parameter.SocialSecurityProfessionKey; professionKey.Save(Connection, Transaction); } else { ORM_CMN_STR_ProfessionKey professionKey = new ORM_CMN_STR_ProfessionKey(); professionKey.SocialSecurityProfessionKey = Parameter.SocialSecurityProfessionKey; professionKey.CMN_STR_Profession_RefID = item.CMN_STR_ProfessionID; professionKey.Tenant_RefID = securityTicket.TenantID; ORM_CMN_Country.Query countryQuery = new ORM_CMN_Country.Query(); countryQuery.Country_ISOCode_Alpha2 = Parameter.Country_ISOCode_Alpha2; countryQuery.IsDeleted = false; countryQuery.Tenant_RefID = securityTicket.TenantID; List <ORM_CMN_Country> countries = ORM_CMN_Country.Query.Search(Connection, Transaction, countryQuery); if (countries.Count != 0) { ORM_CMN_Country country = countries[0]; ORM_CMN_Country_2_EconomicRegion.Query economicRegionToCountryQuery = new ORM_CMN_Country_2_EconomicRegion.Query(); economicRegionToCountryQuery.CMN_Country_RefID = country.CMN_CountryID; economicRegionToCountryQuery.IsDeleted = false; economicRegionToCountryQuery.Tenant_RefID = securityTicket.TenantID; List <ORM_CMN_Country_2_EconomicRegion> economicRegionToCountries = ORM_CMN_Country_2_EconomicRegion.Query.Search(Connection, Transaction, economicRegionToCountryQuery); if (economicRegionToCountries.Count != 0) { ORM_CMN_EconomicRegion.Query economicRegionQuery = new ORM_CMN_EconomicRegion.Query(); economicRegionQuery.CMN_EconomicRegionID = economicRegionToCountries[0].CMN_EconomicRegion_RefID; economicRegionQuery.IsDeleted = false; economicRegionQuery.Tenant_RefID = securityTicket.TenantID; List <ORM_CMN_EconomicRegion> economicRegions = ORM_CMN_EconomicRegion.Query.Search(Connection, Transaction, economicRegionQuery); if (economicRegions.Count != 0) { professionKey.CMN_EconomicRegion_RefID = economicRegions[0].CMN_EconomicRegionID; } } else { ORM_CMN_Country_2_EconomicRegion economicRegionToCountry = new ORM_CMN_Country_2_EconomicRegion(); economicRegionToCountry.CMN_Country_RefID = country.CMN_CountryID; economicRegionToCountry.Tenant_RefID = securityTicket.TenantID; ORM_CMN_EconomicRegion economicRegion = new ORM_CMN_EconomicRegion(); economicRegion.IsEconomicRegionCountry = true; economicRegion.Tenant_RefID = securityTicket.TenantID; economicRegionToCountry.CMN_EconomicRegion_RefID = economicRegion.CMN_EconomicRegionID; economicRegion.Save(Connection, Transaction); economicRegionToCountry.Save(Connection, Transaction); professionKey.CMN_EconomicRegion_RefID = economicRegion.CMN_EconomicRegionID; } } professionKey.Save(Connection, Transaction); } returnValue.Result = item.CMN_STR_ProfessionID; return(returnValue); #endregion UserCode }
protected static FR_L5SK_SSwDC_1618 Execute(DbConnection Connection, DbTransaction Transaction, P_L5SK_SSwDC_1618 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L5SK_SSwDC_1618(); //Put your code here returnValue.Result = new L5SK_SSwDC_1618(); Guid SkillId = Guid.Empty; if (!Parameter.BaseData.IsDeleted) { SkillId = cls_Save_Skill.Invoke(Connection, Transaction, Parameter.BaseData, securityTicket).Result; } else { List <ORM_CMN_STR_Skill_2_Profession> existingProfession = ORM_CMN_STR_Skill_2_Profession.Query.Search(Connection, Transaction, new ORM_CMN_STR_Skill_2_Profession.Query { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, Skill_RefID = Parameter.BaseData.SkillID }).ToList(); if (existingProfession.Count > 0) //cannot delete { List <L5SK_SSwDC_1618_UsedInProfession> usedProfessionList = new List <L5SK_SSwDC_1618_UsedInProfession>(); foreach (var profession in existingProfession) { ORM_CMN_STR_Profession professionName = ORM_CMN_STR_Profession.Query.Search(Connection, Transaction, new ORM_CMN_STR_Profession.Query { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, CMN_STR_ProfessionID = profession.Profession_RefID }).Single(); usedProfessionList.Add(new L5SK_SSwDC_1618_UsedInProfession { ProfessionName = professionName.ProfessionName }); } returnValue.Result.UsedInProfession = usedProfessionList.ToArray(); } List <ORM_CMN_BPT_EMP_Employee_2_Skill> existingEmployee = ORM_CMN_BPT_EMP_Employee_2_Skill.Query.Search(Connection, Transaction, new ORM_CMN_BPT_EMP_Employee_2_Skill.Query { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, Skill_RefID = Parameter.BaseData.SkillID }).ToList(); if (existingEmployee.Count > 0) //cannot delete { List <L5SK_SSwDC_1618_UsedInEmployee> usedEmployeeList = new List <L5SK_SSwDC_1618_UsedInEmployee>(); foreach (var employee in existingEmployee) { L5DO_GSNfEID_1107 employeeName = cls_Get_Staff_Name_for_EmployeeID.Invoke(Connection, Transaction, new P_L5DO_GSNfEID_1107 { EmployeeID = employee.Employee_RefID }, securityTicket).Result; string fullName = employeeName.FirstName + " " + employeeName.LastName; usedEmployeeList.Add(new L5SK_SSwDC_1618_UsedInEmployee { EmployeeName = fullName }); } returnValue.Result.UsedInEmployee = usedEmployeeList.ToArray(); } List <Guid> skillInAppointmentType = ORM_PPS_TSK_Task_RequiredStaff_Skill.Query.Search(Connection, Transaction, new ORM_PPS_TSK_Task_RequiredStaff_Skill.Query { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, CMN_STR_Skill_RefID = Parameter.BaseData.SkillID }).Select(x => x.RequiredStaff_RefID).ToList(); if (skillInAppointmentType.Count > 0) { List <L5SK_SSwDC_1618_UsedInAppointmentType> usedAppointmentTypeList = new List <L5SK_SSwDC_1618_UsedInAppointmentType>(); List <Guid> skillInStaff = ORM_PPS_TSK_Task_RequiredStaff.Query.Search(Connection, Transaction, new ORM_PPS_TSK_Task_RequiredStaff.Query { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, }).Where(x => skillInAppointmentType.Contains(x.PPS_TSK_Task_RequiredStaffID)).Select(a => a.TaskTemplate_RefID).ToList(); List <ORM_PPS_TSK_Task_Template> appointmentTypeList = ORM_PPS_TSK_Task_Template.Query.Search(Connection, Transaction, new ORM_PPS_TSK_Task_Template.Query { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, }).Where(x => skillInStaff.Contains(x.PPS_TSK_Task_TemplateID)).ToList(); foreach (var appointmentType in appointmentTypeList) { usedAppointmentTypeList.Add(new L5SK_SSwDC_1618_UsedInAppointmentType { AppointmentTypeName = appointmentType.TaskTemplateName }); } returnValue.Result.UsedInAppointmentType = usedAppointmentTypeList.ToArray(); } if (existingProfession.Count == 0 && existingEmployee.Count == 0 && skillInAppointmentType.Count == 0) { SkillId = cls_Save_Skill.Invoke(Connection, Transaction, Parameter.BaseData, securityTicket).Result; } } returnValue.Result.ID = SkillId; return(returnValue); #endregion UserCode }