///<summary>
        /// Method Invocation of wrapper classes
        ///<summary>
        protected static FR_L5SK_SSwDC_1618 Invoke(DbConnection Connection, DbTransaction Transaction, string ConnectionString, P_L5SK_SSwDC_1618 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            bool cleanupConnection  = Connection == null;
            bool cleanupTransaction = Transaction == null;

            FR_L5SK_SSwDC_1618 functionReturn = new FR_L5SK_SSwDC_1618();

            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_Skills_withDeleteCheck", ex);
            }
            return(functionReturn);
        }
        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
        }