protected static FR_L6OU_SOUGDwDC_1541 Execute(DbConnection Connection, DbTransaction Transaction, P_L6OU_SOUGDwDC_1541 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L6OU_SOUGDwDC_1541(); //Put your code here returnValue.Result = new L6OU_SOUGDwDC_1541(); Guid OrgUnitId = Guid.Empty; if (!Parameter.BaseData.IsDeleted) { OrgUnitId = cls_Save_OrgsUnitsGeneralData.Invoke(Connection, Transaction, Parameter.BaseData, securityTicket).Result; if (Parameter.UpdateSlots) { cls_CreateUpdate_Slots_for_Practice.Invoke(Connection, Transaction, new P_L5S_SUSfP_1708() { PracticeID = OrgUnitId }, securityTicket); } } else { List <ORM_PPS_TSK_Task_OfficeBooking> existingAppointment = ORM_PPS_TSK_Task_OfficeBooking.Query.Search(Connection, Transaction, new ORM_PPS_TSK_Task_OfficeBooking.Query { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, CMN_STR_Office_RefID = Parameter.BaseData.OrgUnitID }).ToList(); if (existingAppointment.Count > 0) //cannot delete { List <L6OU_SOUGDwDC_1541_UsedInAppointment> usedAppointmentList = new List <L6OU_SOUGDwDC_1541_UsedInAppointment>(); foreach (var appointment in existingAppointment) { ORM_PPS_TSK_Task appointmentName = ORM_PPS_TSK_Task.Query.Search(Connection, Transaction, new ORM_PPS_TSK_Task.Query { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, PPS_TSK_TaskID = appointment.PPS_TSK_Task_RefID }).Single(); usedAppointmentList.Add(new L6OU_SOUGDwDC_1541_UsedInAppointment { AppointmentName = appointmentName.DisplayName }); } returnValue.Result.UsedInAppointment = usedAppointmentList.ToArray(); } List <ORM_CMN_STR_Office> existingParentOrgUnit = ORM_CMN_STR_Office.Query.Search(Connection, Transaction, new ORM_CMN_STR_Office.Query { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, Parent_RefID = Parameter.BaseData.OrgUnitID }).ToList(); if (existingParentOrgUnit.Count > 0) //cannot delete { List <L6OU_SOUGDwDC_1541_UsedInOrgUnit> usedOrgUnitList = new List <L6OU_SOUGDwDC_1541_UsedInOrgUnit>(); foreach (var orgUnit in existingParentOrgUnit) { usedOrgUnitList.Add(new L6OU_SOUGDwDC_1541_UsedInOrgUnit { OrgUnitName = orgUnit.Office_Name }); } returnValue.Result.UsedInOrgUnit = usedOrgUnitList.ToArray(); } List <ORM_CMN_BPT_EMP_Employee_2_Office> existingEmployee = ORM_CMN_BPT_EMP_Employee_2_Office.Query.Search(Connection, Transaction, new ORM_CMN_BPT_EMP_Employee_2_Office.Query { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, CMN_STR_Office_RefID = Parameter.BaseData.OrgUnitID }).ToList(); if (existingEmployee.Count > 0) //cannot delete { List <L6OU_SOUGDwDC_1541_UsedInEmployee> usedEmployeeList = new List <L6OU_SOUGDwDC_1541_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.CMN_BPT_EMP_Employee_RefID }, securityTicket).Result; string fullName = employeeName.FirstName + " " + employeeName.LastName; usedEmployeeList.Add(new L6OU_SOUGDwDC_1541_UsedInEmployee { EmployeeName = fullName }); } returnValue.Result.UsedInEmployee = usedEmployeeList.ToArray(); } if (existingAppointment.Count == 0 && existingParentOrgUnit.Count == 0 && existingEmployee.Count == 0) { OrgUnitId = cls_Save_OrgsUnitsGeneralData.Invoke(Connection, Transaction, Parameter.BaseData, securityTicket).Result; if (Parameter.UpdateSlots) { cls_Delete_Slots_for_PracticeID.Invoke(Connection, Transaction, new P_L5BTS_DSfPID_1103() { OfficeID = Parameter.BaseData.OrgUnitID }, securityTicket); } } } returnValue.Result.ID = OrgUnitId; return(returnValue); #endregion UserCode }
protected static FR_L5DO_SPwDC_1515 Execute(DbConnection Connection, DbTransaction Transaction, P_L5DO_SPwDC_1515 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L5DO_SPwDC_1515(); //Put your code here returnValue.Result = new L5DO_SPwDC_1515(); Guid ProfessionId = Guid.Empty; if (!Parameter.BaseData.IsDeleted) { ProfessionId = cls_Save_Profession.Invoke(Connection, Transaction, Parameter.BaseData, securityTicket).Result; } else { List <ORM_CMN_BPT_EMP_Employee_2_Profession> existingEmployee = ORM_CMN_BPT_EMP_Employee_2_Profession.Query.Search(Connection, Transaction, new ORM_CMN_BPT_EMP_Employee_2_Profession.Query { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, Profession_RefID = Parameter.BaseData.StaffTypeID }).ToList(); if (existingEmployee.Count > 0) //cannot delete { List <L5DO_SPwDC_1515_UsedInEmployee> usedEmployeeList = new List <L5DO_SPwDC_1515_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 L5DO_SPwDC_1515_UsedInEmployee { EmployeeName = fullName }); } returnValue.Result.UsedInEmployee = usedEmployeeList.ToArray(); } List <ORM_PPS_TSK_Task_RequiredStaff_Profession> existingAppointmentType = ORM_PPS_TSK_Task_RequiredStaff_Profession.Query.Search(Connection, Transaction, new ORM_PPS_TSK_Task_RequiredStaff_Profession.Query { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, CMN_STR_Profession_RefID = Parameter.BaseData.StaffTypeID }).ToList(); if (existingAppointmentType.Count > 0) //cannot delete { List <L5DO_SPwDC_1515_UsedInAppointmentType> usedAppointmentTypeList = new List <L5DO_SPwDC_1515_UsedInAppointmentType>(); foreach (var appointmentType in existingAppointmentType) { ORM_PPS_TSK_Task_RequiredStaff reqStaff = ORM_PPS_TSK_Task_RequiredStaff.Query.Search(Connection, Transaction, new ORM_PPS_TSK_Task_RequiredStaff.Query { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, PPS_TSK_Task_RequiredStaffID = appointmentType.RequiredStaff_RefID }).Single(); ORM_PPS_TSK_Task_Template appointmentTypeName = ORM_PPS_TSK_Task_Template.Query.Search(Connection, Transaction, new ORM_PPS_TSK_Task_Template.Query { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, PPS_TSK_Task_TemplateID = reqStaff.TaskTemplate_RefID }).Single(); usedAppointmentTypeList.Add(new L5DO_SPwDC_1515_UsedInAppointmentType { AppointmentTypeName = appointmentTypeName.TaskTemplateName }); } returnValue.Result.UsedInAppointmentType = usedAppointmentTypeList.ToArray(); } if (existingEmployee.Count == 0 && existingAppointmentType.Count == 0) { ProfessionId = cls_Save_Profession.Invoke(Connection, Transaction, Parameter.BaseData, securityTicket).Result; } } returnValue.Result.ID = 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 }