Exemplo n.º 1
0
        protected static FR_L5MC_RAR_1138 Execute(DbConnection Connection, DbTransaction Transaction, P_L5MC_RAR_1138 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            //Leave UserCode region to enable user code saving
            #region UserCode
            var returnValue = new FR_L5MC_RAR_1138();


            var roles = ORM_HEC_CMT_OfferedRole.Query.Search(Connection, Transaction, new ORM_HEC_CMT_OfferedRole.Query()
            {
                Tenant_RefID = securityTicket.TenantID,
                IsDeleted    = false
            }).ToArray();

            var roleToId = new Dictionary <ECommunityRole, ORM_HEC_CMT_OfferedRole>();
            foreach (var role in roles)
            {
                roleToId.Add(EnumUtils.GetEnumValueByDescription <ECommunityRole>(role.GlobalPropertyMatchingID), role);
            }

            var groupSubscription = ORM_HEC_CMT_GroupSubscription.Query.Search(Connection, Transaction, new ORM_HEC_CMT_GroupSubscription.Query()
            {
                Tenant_RefID         = securityTicket.TenantID,
                Membership_RefID     = Parameter.HEC_CMT_MembershipID,
                CommunityGroup_RefID = Parameter.HEC_CMT_CommunityGroupID,
                IsDeleted            = false
            }).Single();

            var r2gs = ORM_HEC_CMT_OfferedRoles_2_GroupSubscription.Query.Search(Connection, Transaction, new ORM_HEC_CMT_OfferedRoles_2_GroupSubscription.Query()
            {
                Tenant_RefID = securityTicket.TenantID,
                HEC_CMT_GroupSubscription_RefID = groupSubscription.HEC_CMT_GroupSubscriptionID,
                IsDeleted = false
            }).ToArray();

            foreach (var r2g in r2gs)
            {
                var currentRole = roleToId.ToArray().Single(s => s.Value.HEC_CMT_OfferedRoleID == r2g.HEC_CMT_OfferedRole_RefID).Key;
                if (currentRole >= ECommunityRole.Administrator)
                {
                    r2g.IsDeleted = true;
                    r2g.Save(Connection, Transaction);
                }
            }

            return(returnValue);

            #endregion UserCode
        }
Exemplo n.º 2
0
 ///<summary>
 /// Ivokes the method with the given Connection, leaving it open if no exceptions occured
 ///<summary>
 public static FR_L5MC_RAR_1138 Invoke(DbConnection Connection, P_L5MC_RAR_1138 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
 {
     return(Invoke(Connection, null, null, Parameter, securityTicket));
 }
Exemplo n.º 3
0
        ///<summary>
        /// Method Invocation of wrapper classes
        ///<summary>
        protected static FR_L5MC_RAR_1138 Invoke(DbConnection Connection, DbTransaction Transaction, string ConnectionString, P_L5MC_RAR_1138 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            bool cleanupConnection  = Connection == null;
            bool cleanupTransaction = Transaction == null;

            FR_L5MC_RAR_1138 functionReturn = new FR_L5MC_RAR_1138();

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