protected static FR_Guids Execute(DbConnection Connection, DbTransaction Transaction, P_L5ME_SRP_1317 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_Guids();
            //Put your code here

            List <Guid> resultID = new List <Guid>();
            foreach (var productParam in Parameter.RecommendedProduct)
            {
                ORM_HEC_DIA_RecommendedProduct existingProduct = ORM_HEC_DIA_RecommendedProduct.Query.Search(Connection, Transaction, new ORM_HEC_DIA_RecommendedProduct.Query
                {
                    HEC_DIA_RecommendedProductID = productParam.HEC_DIA_RecommendedProductID,
                    IsDeleted    = false,
                    Tenant_RefID = securityTicket.TenantID
                }).SingleOrDefault();

                if (!productParam.IsDeleted)
                {
                    Guid ProductID   = productParam.ProductID;
                    Guid DiagnosisID = productParam.DiagnoseID;

                    if (existingProduct == null)
                    {
                        existingProduct = new ORM_HEC_DIA_RecommendedProduct();
                        existingProduct.HEC_DIA_RecommendedProductID = productParam.HEC_DIA_RecommendedProductID;
                        existingProduct.PotentialDiagnosis_RefID     = DiagnosisID;
                        existingProduct.HealthcareProduct_RefID      = ProductID;
                        existingProduct.IsDeleted    = false;
                        existingProduct.Tenant_RefID = securityTicket.TenantID;
                        existingProduct.Save(Connection, Transaction);
                    }
                    resultID.Add(existingProduct.HEC_DIA_RecommendedProductID);

                    foreach (var dosageParam in productParam.DosageList)
                    {
                        ORM_HEC_DIA_RecommendedProduct_Dosage existingDosage = ORM_HEC_DIA_RecommendedProduct_Dosage.Query.Search(Connection, Transaction, new ORM_HEC_DIA_RecommendedProduct_Dosage.Query
                        {
                            HEC_DIA_RecommendedProduct_DosageID = dosageParam.HEC_DIA_RecommendedProduct_DosageID,
                            IsDeleted    = false,
                            Tenant_RefID = securityTicket.TenantID
                        }).SingleOrDefault();
                        if (!dosageParam.IsDeleted)
                        {
                            if (existingDosage == null)
                            {
                                existingDosage = new ORM_HEC_DIA_RecommendedProduct_Dosage();
                                existingDosage.HEC_DIA_RecommendedProduct_DosageID = dosageParam.HEC_DIA_RecommendedProduct_DosageID;
                            }
                            existingDosage.IsDefault                = dosageParam.IsDefault;
                            existingDosage.Dosage_RefID             = dosageParam.Dosage_RefID;
                            existingDosage.RecommendedProduct_RefID = existingProduct.HEC_DIA_RecommendedProductID;
                            existingDosage.IsDeleted                = false;
                            existingDosage.Tenant_RefID             = securityTicket.TenantID;
                            existingDosage.Save(Connection, Transaction);
                        }
                        else if (existingDosage != null && dosageParam.IsDeleted)
                        {
                            existingDosage.IsDeleted = true;
                            existingDosage.Save(Connection, Transaction);
                        }
                    }
                }
                else
                {
                    ORM_HEC_DIA_RecommendedProduct_Dosage.Query.SoftDelete(Connection, Transaction, new ORM_HEC_DIA_RecommendedProduct_Dosage.Query
                    {
                        RecommendedProduct_RefID = existingProduct.HEC_DIA_RecommendedProductID,
                        IsDeleted    = false,
                        Tenant_RefID = securityTicket.TenantID
                    });
                    existingProduct.IsDeleted = true;
                    existingProduct.Save(Connection, Transaction);
                }
            }

            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_Guids Invoke(DbConnection Connection, DbTransaction Transaction, P_L5ME_SRP_1317 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
 {
     return(Invoke(Connection, Transaction, null, Parameter, securityTicket));
 }
        ///<summary>
        /// Method Invocation of wrapper classes
        ///<summary>
        protected static FR_Guids Invoke(DbConnection Connection, DbTransaction Transaction, string ConnectionString, P_L5ME_SRP_1317 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            bool cleanupConnection  = Connection == null;
            bool cleanupTransaction = Transaction == null;

            FR_Guids functionReturn = new FR_Guids();

            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_RecommendedProduct", ex);
            }
            return(functionReturn);
        }
 ///<summary>
 /// Opens the connection/transaction for the given connectionString, and closes them when complete
 ///<summary>
 public static FR_Guids Invoke(string ConnectionString, P_L5ME_SRP_1317 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
 {
     return(Invoke(null, null, ConnectionString, Parameter, securityTicket));
 }