Beispiel #1
0
 public AccountIdentity generateLastPartAccountNumber()
 {
     try
     {
         var obj = new AccountIdentity();
         db.TACCT_ID.Add(obj);
         db.SaveChanges();
         return(obj);
     }
     catch
     {
         return(null);
     }
 }
Beispiel #2
0
        public Account createNewClientAccount(string usrNbr, string ctryCD, string crcyCD, string langCD, string clientTCD)
        {
            var newAcct      = new Account();
            var ctryCrcy     = new CountryCurrency();
            var newAcctIdent = new AccountIdentity();

            try
            {
                var acctIdent = newAcctIdent.generateLastPartAccountNumber();
                if ((clientTCD != "1" && clientTCD != "3") || acctIdent == null)
                {
                    return(null);
                }

                //get param
                string acctNbr         = null;
                string ACCT_TCD        = null;
                string ACCT_NAME       = null;
                string acctCrcyCD      = null;
                string acctCulInfo     = null;
                string lastPartAcctNbr = Convert.ToString(acctIdent.ACCT_ID);

                if (clientTCD == "1")
                {
                    ACCT_TCD = "1";
                    //currentLength = db.TACCT.Where(x => x.ACCT_TCD == ACCT_TCD && x.ACCT_NBR.StartsWith(ctryCD)).ToList().Count();
                    acctNbr   = ctryCD + "C" + lastPartAcctNbr;
                    ACCT_NAME = "Compte Courant Particulier";

                    acctCrcyCD  = ctryCrcy.getCurrencyByCountry(ctryCD);
                    acctCulInfo = ctryCrcy.getCultureInfoByCountryAndLanguage(ctryCD, langCD);
                }

                if (clientTCD == "3")
                {
                    ACCT_TCD = "3";
                    //currentLength = db.TACCT.Where(x => x.ACCT_TCD == ACCT_TCD && x.ACCT_NBR.StartsWith(ctryCD)).ToList().Count();
                    acctNbr   = ctryCD + "X" + lastPartAcctNbr;
                    ACCT_NAME = "Compte Carte Particulier";

                    acctCrcyCD  = crcyCD;
                    acctCulInfo = ctryCrcy.getCultureInfoByCurrencyCD(crcyCD, langCD);
                }

                if (string.IsNullOrWhiteSpace(acctNbr) || acctNbr.Length != 12 ||
                    string.IsNullOrWhiteSpace(acctCrcyCD) || string.IsNullOrWhiteSpace(acctCulInfo))
                {
                    throw new Exception();
                }

                newAcct.ACCT_TCD       = ACCT_TCD;
                newAcct.CRCY_CD        = acctCrcyCD;
                newAcct.ACCT_SCD       = "01";
                newAcct.ACCT_NBR       = acctNbr;
                newAcct.ACCT_NAME      = ACCT_NAME;
                newAcct.ACCT_BAL       = 0.0m;
                newAcct.ACCT_CLTR_INFO = acctCulInfo;
                newAcct.LGC_DEL_IND    = "0";
                newAcct.USR_NBR        = usrNbr;
                newAcct.ACCT_CDT       = DateTime.Now;
                return(newAcct);
            }
            catch
            {
                return(null);
            }
        }