Beispiel #1
0
        ///<summary>
        /// Method Invocation of wrapper classes
        ///<summary>
        protected static FR_L5PR_CFfC_1332 Invoke(DbConnection Connection, DbTransaction Transaction, string ConnectionString, P_L5PR_CFfC_1332 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            bool cleanupConnection  = Connection == null;
            bool cleanupTransaction = Transaction == null;

            FR_L5PR_CFfC_1332 functionReturn = new FR_L5PR_CFfC_1332();

            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_Create_Pharmacy_for_Customer", ex);
            }
            return(functionReturn);
        }
Beispiel #2
0
        protected static FR_L5PR_CFfC_1332 Execute(DbConnection Connection, DbTransaction Transaction, P_L5PR_CFfC_1332 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_L5PR_CFfC_1332();
            returnValue.Result = new L5PR_CFfC_1332();

            var tenantQuery = new ORM_CMN_Tenant.Query()
            {
                TenantITL    = Parameter.Pharmacy_TenantITL,
                Tenant_RefID = securityTicket.TenantID
            };

            var pharmacyTenant = ORM_CMN_Tenant.Query.Search(Connection, Transaction, tenantQuery).SingleOrDefault();

            //Customer doesn't exist
            if (pharmacyTenant == default(ORM_CMN_Tenant))
            {
                pharmacyTenant = new ORM_CMN_Tenant();
                pharmacyTenant.CMN_TenantID       = Guid.NewGuid();
                pharmacyTenant.TenantITL          = Parameter.Pharmacy_TenantITL;
                pharmacyTenant.Tenant_RefID       = securityTicket.TenantID;
                pharmacyTenant.Creation_Timestamp = DateTime.Now;
                pharmacyTenant.Save(Connection, Transaction);
            }

            var bp = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, new ORM_CMN_BPT_BusinessParticipant.Query()
            {
                IsTenant = true,
                IfTenant_Tenant_RefID = pharmacyTenant.CMN_TenantID,
                Tenant_RefID          = securityTicket.TenantID,
                IsDeleted             = false
            }).SingleOrDefault();

            if (bp == default(ORM_CMN_BPT_BusinessParticipant))
            {
                bp = new ORM_CMN_BPT_BusinessParticipant();
                bp.CMN_BPT_BusinessParticipantID = Guid.NewGuid();
                bp.BusinessParticipantITL        = "";
                bp.DisplayName = Parameter.Pharmacy_CompanyName;
                bp.IsCompany   = true;
                bp.IfCompany_CMN_COM_CompanyInfo_RefID = Guid.NewGuid();
                bp.IsTenant = true;
                bp.IfTenant_Tenant_RefID = pharmacyTenant.CMN_TenantID;
                bp.Tenant_RefID          = securityTicket.TenantID;
                bp.Creation_Timestamp    = DateTime.Now;
                bp.Save(Connection, Transaction);
            }

            returnValue.Result.Pharmacy_TenantID = pharmacyTenant.CMN_TenantID;
            returnValue.Result.Pharmacy_BusinessParticipantID = bp.CMN_BPT_BusinessParticipantID;

            return(returnValue);

            #endregion UserCode
        }