Exemplo n.º 1
0
        protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5AC_SA_1046 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_Guid();

            var bp = new ORM_CMN_BPT_BusinessParticipant()
            {
                CMN_BPT_BusinessParticipantID = Guid.NewGuid(),
                Tenant_RefID    = securityTicket.TenantID,
                IsNaturalPerson = true,
                IfNaturalPerson_CMN_PER_PersonInfo_RefID = Guid.NewGuid(),
                DisplayName = Parameter.Title + " " + Parameter.FirstName + " " + Parameter.LastName
            };
            bp.Save(Connection, Transaction);

            var personInfo = new ORM_CMN_PER_PersonInfo()
            {
                CMN_PER_PersonInfoID = bp.IfNaturalPerson_CMN_PER_PersonInfo_RefID,
                Tenant_RefID         = securityTicket.TenantID,
                Title         = Parameter.Title,
                FirstName     = Parameter.FirstName,
                LastName      = Parameter.LastName,
                PrimaryEmail  = Parameter.Email,
                Address_RefID = Guid.NewGuid()
            };
            personInfo.Save(Connection, Transaction);

            var address = new ORM_CMN_Address()
            {
                CMN_AddressID   = personInfo.Address_RefID,
                Tenant_RefID    = securityTicket.TenantID,
                Street_Name     = Parameter.StreetName,
                Street_Number   = Parameter.StreetNumber,
                City_Name       = Parameter.CityName,
                City_PostalCode = Parameter.CityPostalCode,
                Country_Name    = Parameter.CountryName
            };
            address.Save(Connection, Transaction);

            var bptUser = new ORM_CMN_BPT_USR_User()
            {
                CMN_BPT_USR_UserID        = Guid.NewGuid(),
                Tenant_RefID              = securityTicket.TenantID,
                BusinessParticipant_RefID = bp.CMN_BPT_BusinessParticipantID,
                Username = Parameter.Email
            };

            bptUser.Save(Connection, Transaction);

            var    cryptoUtils = new CryptoUtils();
            string passSalt    = cryptoUtils.GenerateRandomSalt(32);

            var bptUserPass = new ORM_CMN_BPT_USR_User_Password()
            {
                CMN_BPT_USR_User_PasswordID = Guid.NewGuid(),
                CMN_BPT_USR_User_RefID      = bptUser.CMN_BPT_USR_UserID,
                Tenant_RefID       = securityTicket.TenantID,
                Password_Salt      = passSalt,
                Password_Hash      = cryptoUtils.GenerateSaltedHash(Parameter.Password, passSalt),
                Password_Algorithm = cryptoUtils.GetHashAlgorithName(),
                IsActive           = Parameter.IsActivated
            };

            bptUserPass.Save(Connection, Transaction);

            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 membershipType = ORM_HEC_CMT_Community_OfferedMembershipType.Query.Search(Connection, Transaction, new ORM_HEC_CMT_Community_OfferedMembershipType.Query()
            {
                Tenant_RefID           = securityTicket.TenantID,
                IsDeleted              = false,
                IsAvailableFor_Tenants = Parameter.IsTenant,
                IsAvailableFor_Doctors = !Parameter.IsTenant
            }).Single();

            var member = new ORM_HEC_CMT_Membership()
            {
                CommunityMembershipITL    = Guid.NewGuid().ToString(),
                HEC_CMT_MembershipID      = Guid.NewGuid(),
                Tenant_RefID              = securityTicket.TenantID,
                Community_RefID           = community.HEC_CMT_CommunityID,
                MembershipType_RefID      = membershipType.HEC_CMT_Community_OfferedMembershipTypeID,
                BusinessParticipant_RefID = bp.CMN_BPT_BusinessParticipantID
            };
            member.Save(Connection, Transaction);

            returnValue.Result = bptUser.CMN_BPT_USR_UserID;

            return(returnValue);

            #endregion UserCode
        }
Exemplo n.º 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_L5AC_SA_1046 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
 {
     return(Invoke(Connection, Transaction, null, Parameter, securityTicket));
 }
Exemplo n.º 3
0
        ///<summary>
        /// Method Invocation of wrapper classes
        ///<summary>
        protected static FR_Guid Invoke(DbConnection Connection, DbTransaction Transaction, string ConnectionString, P_L5AC_SA_1046 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_Account", ex);
            }
            return(functionReturn);
        }
Exemplo n.º 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_L5AC_SA_1046 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
 {
     return(Invoke(null, null, ConnectionString, Parameter, securityTicket));
 }