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 }
///<summary> /// Invokes the method for the given Connection, and Transaction, leaving them open/not commited if no exceptions occured ///<summary> public static FR_L6OU_SOUGDwDC_1541 Invoke(DbConnection Connection, DbTransaction Transaction, P_L6OU_SOUGDwDC_1541 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { return(Invoke(Connection, Transaction, null, Parameter, securityTicket)); }
///<summary> /// Method Invocation of wrapper classes ///<summary> protected static FR_L6OU_SOUGDwDC_1541 Invoke(DbConnection Connection, DbTransaction Transaction, string ConnectionString, P_L6OU_SOUGDwDC_1541 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { bool cleanupConnection = Connection == null; bool cleanupTransaction = Transaction == null; FR_L6OU_SOUGDwDC_1541 functionReturn = new FR_L6OU_SOUGDwDC_1541(); try { if (cleanupConnection == true) { Connection = CSV2Core_MySQL.Support.DBSQLSupport.CreateConnection(ConnectionString); Connection.Open(); } if (cleanupTransaction == true) { Transaction = Connection.BeginTransaction(); } functionReturn = Execute(Connection, Transaction, Parameter, securityTicket); #region Cleanup Connection/Transaction //Commit the transaction if (cleanupTransaction == true) { Transaction.Commit(); } //Close the connection if (cleanupConnection == true) { Connection.Close(); } #endregion } catch (Exception ex) { try { if (cleanupTransaction == true && Transaction != null) { Transaction.Rollback(); } } catch { } try { if (cleanupConnection == true && Connection != null) { Connection.Close(); } } catch { } throw new Exception("Exception occured in method cls_Save_OrgsUnitsGeneralData_wihtDeleteCheck", ex); } return(functionReturn); }
///<summary> /// Opens the connection/transaction for the given connectionString, and closes them when complete ///<summary> public static FR_L6OU_SOUGDwDC_1541 Invoke(string ConnectionString, P_L6OU_SOUGDwDC_1541 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { return(Invoke(null, null, ConnectionString, Parameter, securityTicket)); }