protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5SCBD_1454 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            //Leave UserCode region to enable user code saving
            #region UserCode
            var returnValue = new FR_Guid();
            //Put your code here

            #region Save

            ORM_CMN_PRO_Catalog       catalog = new ORM_CMN_PRO_Catalog();
            ORM_CMN_PRO_MasterCatalog mc      = new ORM_CMN_PRO_MasterCatalog();

            #region Delete
            if (Parameter.isDeleted == true)
            {
                /*
                 * @Delete Catalog
                 * */
                catalog.Load(Connection, Transaction, Parameter.CatalogID);
                catalog.IsDeleted = true;
                catalog.Save(Connection, Transaction);

                /*
                 * @Delete Catalog's master catalog
                 * */
                ORM_CMN_PRO_MasterCatalog masterCata = new ORM_CMN_PRO_MasterCatalog();
                masterCata.Load(Connection, Transaction, catalog.CMN_PRO_MasterCatalog_RefID);
                masterCata.IsDeleted = true;
                masterCata.Save(Connection, Transaction);

                /*
                 * @Delete CMN_PRO_Catalog_Revisions
                 * */
                var catalogRevisionQuery = new ORM_CMN_PRO_Catalog_Revision.Query();
                catalogRevisionQuery.Tenant_RefID          = securityTicket.TenantID;
                catalogRevisionQuery.CMN_PRO_Catalog_RefID = Parameter.CatalogID;

                var catalogRevisionDel = ORM_CMN_PRO_Catalog_Revision.Query.Search(Connection, Transaction, catalogRevisionQuery);
                if (catalogRevisionDel != null)
                {
                    foreach (var item in catalogRevisionDel)
                    {
                        ORM_CMN_PRO_Catalog_ProductGroup.Query searchProductGroupQuery = new ORM_CMN_PRO_Catalog_ProductGroup.Query();
                        searchProductGroupQuery.Catalog_Revision_RefID = item.CMN_PRO_Catalog_RevisionID;
                        List <ORM_CMN_PRO_Catalog_ProductGroup> revisionGroups = ORM_CMN_PRO_Catalog_ProductGroup.Query.Search(Connection, Transaction, searchProductGroupQuery);

                        /*
                         * @Deep delete product groups
                         * */
                        P_L5CA_DCPG_1049 delParam = new P_L5CA_DCPG_1049();
                        foreach (var group in revisionGroups)
                        {
                            delParam.ProductGroupID = group.CMN_PRO_Catalog_ProductGroupID;
                            cls_Delete_Catalog_Product_Group.Invoke(Connection, Transaction, delParam);
                        }

                        /*
                         * @Delete products that are in root of catalog revision (not in group)
                         * */
                        ORM_CMN_PRO_Catalog_Product.Query revisionProductsQuery = new ORM_CMN_PRO_Catalog_Product.Query();
                        revisionProductsQuery.CMN_PRO_Catalog_Revision_RefID = item.CMN_PRO_Catalog_RevisionID;
                        List <ORM_CMN_PRO_Catalog_Product> revisionProducts = ORM_CMN_PRO_Catalog_Product.Query.Search(Connection, Transaction, revisionProductsQuery);

                        foreach (var product in revisionProducts)
                        {
                            product.IsDeleted = true;
                            product.Save(Connection, Transaction);
                        }

                        /*
                         * @Delete catalog revision
                         * */
                        item.IsDeleted = true;
                        item.Save(Connection, Transaction);
                    }
                }

                returnValue.Result = Parameter.CatalogID;
                return(returnValue);
            }
            #endregion


            /*
             * @save CMN_PRO_Catalogs
             * */
            if (Parameter.CatalogID == Guid.Empty)
            {
                mc.CMN_PRO_MasterCatalogID = Guid.NewGuid();
                mc.Catalog_Description     = new Dict();
                mc.Catalog_Name            = Parameter.CatalogName_Dict;
                mc.CatalogPublishing_DefaultCurrency_RefID = Parameter.Catalog_Currency_RefID;
                mc.CatalogPublishing_DefaultLanguage_RefID = Parameter.Catalog_Language_RefID;
                mc.Creation_Timestamp = DateTime.Now;
                mc.Save(Connection, Transaction);

                catalog.CMN_PRO_CatalogID           = Guid.NewGuid();
                catalog.CMN_PRO_MasterCatalog_RefID = mc.CMN_PRO_MasterCatalogID;
                catalog.Tenant_RefID       = securityTicket.TenantID;
                catalog.IsPublicCatalog    = Parameter.isPublic;
                catalog.CatalogCodeITL     = RandomString.Generate(8);
                catalog.Creation_Timestamp = DateTime.Now;
                catalog.IsDeleted          = false;
                if (Parameter.Catalog_Currency_RefID != Guid.Empty)
                {
                    catalog.Catalog_Currency_RefID = Parameter.Catalog_Currency_RefID;
                }
                if (Parameter.Catalog_Language_RefID != Guid.Empty)
                {
                    catalog.Catalog_Language_RefID = Parameter.Catalog_Language_RefID;
                }

                catalog.Save(Connection, Transaction);

                /*
                 * @save Revision
                 * */

                ORM_CMN_PRO_Catalog_Revision rev = new ORM_CMN_PRO_Catalog_Revision();
                rev.CMN_PRO_Catalog_RevisionID = Guid.NewGuid();
                rev.CMN_PRO_Catalog_RefID      = catalog.CMN_PRO_CatalogID;
                rev.Tenant_RefID                = securityTicket.TenantID;
                rev.Creation_Timestamp          = DateTime.Now;
                rev.CatalogRevision_Description = "Initial revision for catalog ";
                rev.CatalogRevision_Name        = "Initial catalog revision";
                rev.IsDeleted      = false;
                rev.RevisionNumber = 1;
                rev.Save(Connection, Transaction);

                /*
                 * @save Default Catalog ProductGroup
                 * */

                ORM_CMN_PRO_Catalog_ProductGroup defaultProductGroup = new ORM_CMN_PRO_Catalog_ProductGroup();
                defaultProductGroup.Catalog_Revision_RefID           = rev.CMN_PRO_Catalog_RevisionID;
                defaultProductGroup.CMN_PRO_Catalog_ProductGroupID   = Guid.NewGuid();
                defaultProductGroup.CatalogProductGroup_Name         = Parameter.CatalogName_Dict.Contents.First().Content;
                defaultProductGroup.CatalogProductGroup_Parent_RefID = Guid.Empty;
                defaultProductGroup.Tenant_RefID = securityTicket.TenantID;
                defaultProductGroup.Save(Connection, Transaction);
            }
            else
            {
                /*
                 * @edit Catalog
                 * */

                catalog.Load(Connection, Transaction, Parameter.CatalogID);
                catalog.Tenant_RefID    = securityTicket.TenantID;
                catalog.IsPublicCatalog = Parameter.isPublic;
                catalog.IsDeleted       = false;
                if (Parameter.Catalog_Currency_RefID != Guid.Empty)
                {
                    catalog.Catalog_Currency_RefID = Parameter.Catalog_Currency_RefID;
                }
                if (Parameter.Catalog_Language_RefID != Guid.Empty)
                {
                    catalog.Catalog_Language_RefID = Parameter.Catalog_Language_RefID;
                }

                catalog.Save(Connection, Transaction);

                mc.Load(Connection, Transaction, catalog.CMN_PRO_MasterCatalog_RefID);
                mc.Catalog_Name = Parameter.CatalogName_Dict;
                mc.CatalogPublishing_DefaultCurrency_RefID = Parameter.Catalog_Currency_RefID;
                mc.CatalogPublishing_DefaultLanguage_RefID = Parameter.Catalog_Language_RefID;

                mc.Save(Connection, Transaction);
            }



            #endregion
            returnValue.Result = Parameter.CatalogID;

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

            FR_Guid functionReturn = new FR_Guid();

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