Example #1
0
 /// <summary>
 /// 添加一条新的公司帐号
 /// </summary>
 /// <param name="account">account对象</param>
 public static void AddAccount(Account account)
 {
     if (FindAccountByAccountNumber(account.AccountNumber) != null)
     {
         throw new DuplicateAccountException("LoginName exist");
     }
     if (GetAccountById(account.AccountId) != null)
     {
         throw new DuplicateAccountException("AccountId exisit");
     }
     accounts.Add(account);
     Provider.AddAccount(account);
     Trace.WriteLine(string.Format("AddAccount: AccountId={0} LoginName={1}", account.AccountId, account.AccountNumber));
 }
        public IActionResult createAccount([FromBody] dynamic obj)
        {
            if (Convert.ToInt32(obj.CustomerId) == 0)
            {
                _log4net.Warn("User has sent some invalid CustomerId " + Convert.ToInt32(obj.CustomerId));
                return(NotFound());
            }
            try
            {
                AccountCreationStatus acs, acs1 = new AccountCreationStatus();


                acs = _Provider.AddAccount(Convert.ToInt32(obj.CustomerId), "Savings");
                _log4net.Info("Savings account has been successfully created");
                acs1 = _Provider.AddAccount(Convert.ToInt32(obj.CustomerId), "Current");
                _log4net.Info("Current account has been successfully created");
                return(Ok(acs1));
            }
            catch (Exception e)
            {
                _log4net.Error(e.Message);
                throw e;
            }
        }