///<summary> /// Method Invocation of wrapper classes ///<summary> protected static FR_L5MC_MRR_1440 Invoke(DbConnection Connection, DbTransaction Transaction, string ConnectionString, P_L5MC_MRR_1440 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { bool cleanupConnection = Connection == null; bool cleanupTransaction = Transaction == null; FR_L5MC_MRR_1440 functionReturn = new FR_L5MC_MRR_1440(); 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_Make_Role_Request", ex); } return(functionReturn); }
protected static FR_L5MC_MRR_1440 Execute(DbConnection Connection, DbTransaction Transaction, P_L5MC_MRR_1440 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { //Leave UserCode region to enable user code saving #region UserCode var returnValue = new FR_L5MC_MRR_1440(); returnValue.Result = new L5MC_MRR_1440(); var community = ORM_HEC_CMT_Community.Query.Search(Connection, Transaction, new ORM_HEC_CMT_Community.Query() { Tenant_RefID = securityTicket.TenantID, IsDeleted = false, IsCommunityOperatedByThisTenant = true }).Single(); var role = ORM_HEC_CMT_OfferedRole.Query.Search(Connection, Transaction, new ORM_HEC_CMT_OfferedRole.Query() { GlobalPropertyMatchingID = Parameter.Role_GlobalPropertyMatchingID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).Single(); var memberRequests = cls_Get_Requests_for_GroupID_and_MemberID.Invoke(Connection, Transaction, new P_L5AC_GRfGaMs_1449() { GroupID = Parameter.HEC_CMT_CommunityGroupID, MemberID = Parameter.HEC_CMT_MembershipID }, securityTicket).Result; var memberRoles = cls_Get_MemberRoles_for_GroupID.Invoke(Connection, Transaction, new P_L5MC_GMRfGMID_1505() { GroupID = Parameter.HEC_CMT_CommunityGroupID, MemberID = Parameter.HEC_CMT_MembershipID }, securityTicket).Result.Roles; var subscription = ORM_HEC_CMT_GroupSubscription.Query.Search(Connection, Transaction, new ORM_HEC_CMT_GroupSubscription.Query() { Tenant_RefID = securityTicket.TenantID, IsDeleted = false, Membership_RefID = Parameter.HEC_CMT_MembershipID, CommunityGroup_RefID = Parameter.HEC_CMT_CommunityGroupID }).SingleOrDefault(); var prevRequestStillActive = memberRequests.Where(w => w.Role_GlobalPropertyMatchingID == Parameter.Role_GlobalPropertyMatchingID).Count() > 0; var isThereCutomerRole = memberRoles.Where(w => w.GlobalPropertyMatchingID == Parameter.Role_GlobalPropertyMatchingID).Count() > 0; if (subscription == null || prevRequestStillActive && isThereCutomerRole) { returnValue.Result.IsSuccess = false; returnValue.Result.FailReason = new L5MC_MRR_1440_FailReason() { IsntGroupMember = true, IsAlreadyHaveThisRole = isThereCutomerRole, IsAlreadyRequested = prevRequestStillActive, IfAlreadyRequested_RequestID = isThereCutomerRole ? memberRequests.First(w => w.Role_GlobalPropertyMatchingID == Parameter.Role_GlobalPropertyMatchingID).HEC_CMT_GroupSubscription_RequestID : Guid.Empty }; } else { var request = new ORM_HEC_CMT_GroupSubscription_Request() { HEC_CMT_GroupSubscription_RequestID = Guid.NewGuid(), Tenant_RefID = securityTicket.TenantID, Membership_RefID = Parameter.HEC_CMT_MembershipID, CommunityGroup_RefID = Parameter.HEC_CMT_CommunityGroupID, IsRequested = true }; request.Save(Connection, Transaction); var roleRequest = new ORM_HEC_CMT_OfferedRoles_2_GroupSubscriptionRequest() { Tenant_RefID = securityTicket.TenantID, AssignmentID = Guid.NewGuid(), HEC_CMT_OfferedRole_RefID = role.HEC_CMT_OfferedRoleID, HEC_CMT_GroupSubscription_Request_RefID = request.HEC_CMT_GroupSubscription_RequestID }; roleRequest.Save(Connection, Transaction); returnValue.Result.IsSuccess = true; returnValue.Result.HEC_CMT_GroupSubscription_RequestID = request.HEC_CMT_GroupSubscription_RequestID; } return(returnValue); #endregion UserCode }