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

            returnValue.Result = false;

            ORM_USR_Account_2_FunctionLevelRight.Query searchUserRights = new ORM_USR_Account_2_FunctionLevelRight.Query();
            searchUserRights.Account_RefID = Parameter.AccountID;
            searchUserRights.IsDeleted     = false;
            searchUserRights.Tenant_RefID  = securityTicket.TenantID;

            List <ORM_USR_Account_2_FunctionLevelRight> RightsForAccountID = ORM_USR_Account_2_FunctionLevelRight.Query.Search(Connection, Transaction, searchUserRights);

            if (RightsForAccountID == null)
            {
                RightsForAccountID = new List <ORM_USR_Account_2_FunctionLevelRight>();
            }

            #region ASSIGN ADMIN RIGHTS

            if (Parameter.AssignAdministratorRights && Parameter.AdministratorRightID != null && Parameter.AdministratorRightID != Guid.Empty)
            {
                if (RightsForAccountID.Any(r => r.FunctionLevelRight_RefID == Parameter.AdministratorRightID) == false)
                {
                    ORM_USR_Account_2_FunctionLevelRight newRight = new ORM_USR_Account_2_FunctionLevelRight();
                    newRight.Account_RefID            = Parameter.AccountID;
                    newRight.FunctionLevelRight_RefID = Parameter.AdministratorRightID;
                    newRight.Tenant_RefID             = securityTicket.TenantID;
                    newRight.IsDeleted = false;

                    newRight.Save(Connection, Transaction);
                }

                if (RightsForAccountID.Any(r => r.FunctionLevelRight_RefID == Parameter.AdministratorRightID) == true)
                {
                    ORM_USR_Account_2_FunctionLevelRight.Query searchAdmin = new ORM_USR_Account_2_FunctionLevelRight.Query();
                    searchAdmin.IsDeleted                = false;
                    searchAdmin.Account_RefID            = Parameter.AccountID;
                    searchAdmin.FunctionLevelRight_RefID = Parameter.AdministratorRightID;
                    searchAdmin.Tenant_RefID             = securityTicket.TenantID;

                    ORM_USR_Account_2_FunctionLevelRight.Query.SoftDelete(Connection, Transaction, searchAdmin);

                    // Manager is not a manager without ADMIN rights too ( MANAGER -> Admin, Business, Technical rights)
                    // delete business if exists
                    ORM_USR_Account_2_FunctionLevelRight.Query searchBusiness = new ORM_USR_Account_2_FunctionLevelRight.Query();
                    searchBusiness.IsDeleted                = false;
                    searchBusiness.Account_RefID            = Parameter.AccountID;
                    searchBusiness.FunctionLevelRight_RefID = Parameter.BusinessRightID;
                    searchBusiness.Tenant_RefID             = securityTicket.TenantID;

                    ORM_USR_Account_2_FunctionLevelRight.Query.SoftDelete(Connection, Transaction, searchBusiness);

                    // delete technical if exists
                    ORM_USR_Account_2_FunctionLevelRight.Query searchTechnical = new ORM_USR_Account_2_FunctionLevelRight.Query();
                    searchTechnical.IsDeleted                = false;
                    searchTechnical.Account_RefID            = Parameter.AccountID;
                    searchTechnical.FunctionLevelRight_RefID = Parameter.TechnicalRightID;
                    searchTechnical.Tenant_RefID             = securityTicket.TenantID;

                    ORM_USR_Account_2_FunctionLevelRight.Query.SoftDelete(Connection, Transaction, searchTechnical);
                }
            }

            #endregion

            #region ASSIGN MANAGER RIGHTS

            if (Parameter.AssignManagerRights && Parameter.AdministratorRightID != null && Parameter.AdministratorRightID != Guid.Empty && Parameter.BusinessRightID != null && Parameter.BusinessRightID != Guid.Empty && Parameter.TechnicalRightID != null && Parameter.TechnicalRightID != Guid.Empty)
            {
                //add admin
                if (RightsForAccountID.Any(r => r.FunctionLevelRight_RefID == Parameter.AdministratorRightID) == false)
                {
                    ORM_USR_Account_2_FunctionLevelRight newRight = new ORM_USR_Account_2_FunctionLevelRight();
                    newRight.Account_RefID            = Parameter.AccountID;
                    newRight.FunctionLevelRight_RefID = Parameter.AdministratorRightID;
                    newRight.Tenant_RefID             = securityTicket.TenantID;
                    newRight.IsDeleted = false;

                    newRight.Save(Connection, Transaction);
                }

                // add business
                if (RightsForAccountID.Any(r => r.FunctionLevelRight_RefID == Parameter.BusinessRightID) == false)
                {
                    ORM_USR_Account_2_FunctionLevelRight newRight = new ORM_USR_Account_2_FunctionLevelRight();
                    newRight.Account_RefID            = Parameter.AccountID;
                    newRight.FunctionLevelRight_RefID = Parameter.BusinessRightID;
                    newRight.Tenant_RefID             = securityTicket.TenantID;
                    newRight.IsDeleted = false;

                    newRight.Save(Connection, Transaction);
                }

                if (RightsForAccountID.Any(r => r.FunctionLevelRight_RefID == Parameter.BusinessRightID) == true)
                {
                    ORM_USR_Account_2_FunctionLevelRight.Query searchQuery = new ORM_USR_Account_2_FunctionLevelRight.Query();
                    searchQuery.IsDeleted                = false;
                    searchQuery.Account_RefID            = Parameter.AccountID;
                    searchQuery.FunctionLevelRight_RefID = Parameter.BusinessRightID;

                    ORM_USR_Account_2_FunctionLevelRight.Query.SoftDelete(Connection, Transaction, searchQuery);
                }

                //add technical
                if (RightsForAccountID.Any(r => r.FunctionLevelRight_RefID == Parameter.TechnicalRightID) == false)
                {
                    ORM_USR_Account_2_FunctionLevelRight newRight = new ORM_USR_Account_2_FunctionLevelRight();
                    newRight.Account_RefID            = Parameter.AccountID;
                    newRight.FunctionLevelRight_RefID = Parameter.TechnicalRightID;
                    newRight.Tenant_RefID             = securityTicket.TenantID;
                    newRight.IsDeleted = false;

                    newRight.Save(Connection, Transaction);
                }

                if (RightsForAccountID.Any(r => r.FunctionLevelRight_RefID == Parameter.TechnicalRightID) == true)
                {
                    ORM_USR_Account_2_FunctionLevelRight.Query searchQuery = new ORM_USR_Account_2_FunctionLevelRight.Query();
                    searchQuery.IsDeleted                = false;
                    searchQuery.Account_RefID            = Parameter.AccountID;
                    searchQuery.FunctionLevelRight_RefID = Parameter.TechnicalRightID;

                    ORM_USR_Account_2_FunctionLevelRight.Query.SoftDelete(Connection, Transaction, searchQuery);
                }
            }

            #endregion

            #region ASSIGN DEVELOPER RIGHTS

            if (Parameter.AssignDeveloperRights && Parameter.DeveloperRightID != Guid.Empty && Parameter.DeveloperRightID != null)
            {
                if (RightsForAccountID.Any(r => r.FunctionLevelRight_RefID == Parameter.DeveloperRightID) == false)
                {
                    ORM_USR_Account_2_FunctionLevelRight newRight = new ORM_USR_Account_2_FunctionLevelRight();
                    newRight.Account_RefID            = Parameter.AccountID;
                    newRight.FunctionLevelRight_RefID = Parameter.DeveloperRightID;
                    newRight.Tenant_RefID             = securityTicket.TenantID;
                    newRight.IsDeleted = false;

                    newRight.Save(Connection, Transaction);
                }

                if (RightsForAccountID.Any(r => r.FunctionLevelRight_RefID == Parameter.DeveloperRightID) == true)
                {
                    ORM_USR_Account_2_FunctionLevelRight.Query searchQuery = new ORM_USR_Account_2_FunctionLevelRight.Query();
                    searchQuery.IsDeleted                = false;
                    searchQuery.Account_RefID            = Parameter.AccountID;
                    searchQuery.FunctionLevelRight_RefID = Parameter.DeveloperRightID;

                    ORM_USR_Account_2_FunctionLevelRight.Query.SoftDelete(Connection, Transaction, searchQuery);
                }
            }

            #endregion

            returnValue.Result = true;

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

            FR_Bool functionReturn = new FR_Bool();

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