Beispiel #1
0
        protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_MD_SCPHIPs_1341 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

            var participatingHIPs = ORM_CMN_CTR_Contract_Party.Query.Search(Connection, Transaction, new ORM_CMN_CTR_Contract_Party.Query()
            {
                Contract_RefID = Parameter.ContractID,
                Tenant_RefID   = securityTicket.TenantID,
                IsDeleted      = false
            });

            if (participatingHIPs.Count != 0)
            {
                foreach (var hip in participatingHIPs)
                {
                    if (Parameter.HipIDs.Length == 0 || !Parameter.HipIDs.Any(hid => hid == hip.Undersigning_BusinessParticipant_RefID))
                    {
                        hip.IsDeleted = true;
                        hip.Modification_Timestamp = DateTime.Now;

                        hip.Save(Connection, Transaction);
                    }
                }
            }


            var contractPartiesRolesHIP = ORM_CMN_CTR_Contract_Role.Query.Search(Connection, Transaction, new ORM_CMN_CTR_Contract_Role.Query()
            {
                IsDeleted    = false,
                Tenant_RefID = securityTicket.TenantID,
                RoleName     = "Health Insurance Provider"
            }).SingleOrDefault();

            if (contractPartiesRolesHIP == null)
            {
                contractPartiesRolesHIP = new ORM_CMN_CTR_Contract_Role();
                contractPartiesRolesHIP.CMN_CTR_Contract_RoleID = Guid.NewGuid();
                contractPartiesRolesHIP.IsDeleted              = false;
                contractPartiesRolesHIP.Tenant_RefID           = securityTicket.TenantID;
                contractPartiesRolesHIP.Creation_Timestamp     = DateTime.Now;
                contractPartiesRolesHIP.Modification_Timestamp = DateTime.Now;
                contractPartiesRolesHIP.RoleName = "Health Insurance Provider";

                contractPartiesRolesHIP.Save(Connection, Transaction);
            }

            foreach (var hipBptID in Parameter.HipIDs)
            {
                if (!participatingHIPs.Any(hip => hip.Undersigning_BusinessParticipant_RefID == hipBptID))
                {
                    var contractParty = new ORM_CMN_CTR_Contract_Party();
                    contractParty.CMN_CTR_Contract_PartyID = Guid.NewGuid();
                    contractParty.Contract_RefID           = Parameter.ContractID;
                    contractParty.Creation_Timestamp       = DateTime.Now;
                    contractParty.Modification_Timestamp   = DateTime.Now;
                    contractParty.Party_ContractRole_RefID = contractPartiesRolesHIP.CMN_CTR_Contract_RoleID;
                    contractParty.Tenant_RefID             = securityTicket.TenantID;
                    contractParty.Undersigning_BusinessParticipant_RefID = hipBptID;

                    contractParty.Save(Connection, Transaction);
                }
            }

            return(returnValue);

            #endregion UserCode
        }
Beispiel #2
0
 ///<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_MD_SCPHIPs_1341 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
 {
     return(Invoke(Connection, Transaction, null, Parameter, securityTicket));
 }
Beispiel #3
0
        ///<summary>
        /// Method Invocation of wrapper classes
        ///<summary>
        protected static FR_Guid Invoke(DbConnection Connection, DbTransaction Transaction, string ConnectionString, P_MD_SCPHIPs_1341 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_Contract_Participating_HIPs", ex);
            }
            return(functionReturn);
        }
Beispiel #4
0
 ///<summary>
 /// Opens the connection/transaction for the given connectionString, and closes them when complete
 ///<summary>
 public static FR_Guid Invoke(string ConnectionString, P_MD_SCPHIPs_1341 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
 {
     return(Invoke(null, null, ConnectionString, Parameter, securityTicket));
 }