예제 #1
0
        public bool SaveCustomerId(TurnKeyBrokerSignUpDataContext dataContext, RegistrationInfo info, string StoreURI)
        {
            bool bCustomerIdGenerated = false;

            try
            {
                if (dataContext == null)
                {
                    dataContext = new TurnKeyBrokerSignUpDataContext();
                }

                info.CustomerId = GenerateAccountNumber(info.firstName, info.lastName);

                int customer_id_generated_count = 0;

                var account = (from s in dataContext.tb_accounts
                               //where s.email_address == info.EmailAddress
                               where s.account_id == info.AccountId &&
                               s.active == true && s.deleted == false &&
                               s.storeURI == StoreURI
                               select s).FirstOrDefault();

                while (true)
                {
                    var a = (from s in dataContext.tb_accounts
                             where s.customer_id == info.CustomerId
                             select s).FirstOrDefault();

                    if (a == null)
                    {
                        bCustomerIdGenerated = true;
                        break;
                    }
                    else
                    {
                        regModel.CustomerId = GenerateAccountNumber(info.firstName, info.lastName);
                    }
                    customer_id_generated_count++;
                    if (customer_id_generated_count > 1000)
                    {
                        break;
                    }
                }



                if (account != null)
                {
                    account.customer_id = info.CustomerId;
                    if (!isDebug)
                    {
                        dataContext.SubmitChanges();
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(bCustomerIdGenerated);
        }
예제 #2
0
        /// This method will save or update easy ofac data in db
        /// <param name="account_id"></param>
        /// <param name="account_type_id"></param>
        /// <param name="CustomerId"></param>
        /// <param name="firstName"></param>
        /// <param name="lastName"></param>
        /// </summary>
        /// <returns>bool</returns>
        ///
        public bool SaveEasyOFACDetails(int account_type_id, int account_id, string CustomerId, string firstName, string lastName)
        {
            bool status = true;

            string url         = string.Empty;
            var    dataContext = new TurnKeyBrokerSignUpDataContext();

            try
            {
                if (account_type_id == 1 || account_type_id == 2)
                {
                    url = ConfigurationManager.AppSettings["EasyOFACEndPoint"].ToString() + "addCustomer";
                }
                else
                {
                    var _instEntity = (from i in dataContext.tb_institutional_signups.Where(i => i.account_id == account_id) select i).FirstOrDefault();
                    if (_instEntity != null)
                    {
                        regModel.firstName = _instEntity.account_name;
                    }
                    url = ConfigurationManager.AppSettings["EasyOFACEndPoint"].ToString() + "addCompany";
                }
                string  response = objHelper.EasyOFACApiExecution(url, CustomerId, firstName, lastName, account_type_id);
                JObject o        = JObject.Parse(response);
                if (!response.Contains("failed"))
                {
                    if (account_type_id == 1 || account_type_id == 2)
                    {
                        tb_EasyOFACHistory _obj = new tb_EasyOFACHistory();
                        _obj.AccountNumber    = (string)o["id"];
                        _obj.CustomerDateTime = DateTime.Now;
                        _obj.CustomerKyc      = (bool?)o["customer_kyc"];
                        _obj.Status           = (string)o["customer_status"];
                        dataContext.tb_EasyOFACHistories.InsertOnSubmit(_obj);
                        dataContext.SubmitChanges();
                        status = true;
                    }
                    else
                    {
                        tb_EasyOFACHistory _obj = new tb_EasyOFACHistory();
                        _obj.AccountNumber    = (string)o["id"];
                        _obj.CustomerDateTime = DateTime.Now;
                        _obj.CustomerKyc      = (bool?)o["company_kyc"];
                        _obj.Status           = (string)o["company_statusCurrent"];
                        dataContext.tb_EasyOFACHistories.InsertOnSubmit(_obj);
                        dataContext.SubmitChanges();
                        status = true;
                    }
                }
                else
                {
                    //save failed response
                    if (account_type_id == 1 || account_type_id == 2)
                    {
                        tb_EasyOFACHistory _obj = new tb_EasyOFACHistory();
                        _obj.AccountNumber    = (string)o["id"];
                        _obj.CustomerDateTime = DateTime.Now;
                        _obj.Status           = (string)o["customer_status"];
                        dataContext.tb_EasyOFACHistories.InsertOnSubmit(_obj);
                        dataContext.SubmitChanges();
                        status = false;
                    }
                    else
                    {
                        tb_EasyOFACHistory _obj = new tb_EasyOFACHistory();
                        _obj.AccountNumber    = (string)o["id"];
                        _obj.CustomerDateTime = DateTime.Now;
                        _obj.Status           = (string)o["company_statusCurrent"];
                        dataContext.tb_EasyOFACHistories.InsertOnSubmit(_obj);
                        dataContext.SubmitChanges();
                        status = false;
                    }
                }
            }
            catch (Exception ex)
            {
                Elmah.ErrorLog.GetDefault(System.Web.HttpContext.Current).Log(new Elmah.Error(ex, System.Web.HttpContext.Current));
            }

            return(status);
        }