コード例 #1
0
ファイル: AccountService.cs プロジェクト: buibup/Assignment-1
        public void OpenNewAccount(string accountNo)
        {
            IAccountData objAccountData = null;

            try
            {
                objAccountData = Builder.AccountData();

                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.RequiresNew))
                {
                    if (objAccountData.CheckAccount(accountNo))
                    {
                        throw new Exception("Already account.");
                    }
                    if (!objAccountData.AddAccount(accountNo, 0))
                    {
                        throw new Exception("Error: Can not add data");
                    }
                    scope.Complete();
                }
            }
            catch
            {
                throw;
            }
            finally
            {
                if (objAccountData != null)
                {
                    objAccountData.Dispose();
                }
            }
        }
コード例 #2
0
ファイル: AccountService.cs プロジェクト: buibup/Assignment-1
        public bool AddAccount(string accountNo, decimal balance)
        {
            try
            {
                // Validation Exist AccountNo
                if (CheckAccount(accountNo))
                {
                    return(false);
                }

                using (IAccountData accountData = Builder.AccountData())
                {
                    return(accountData.AddAccount(accountNo, balance));
                }
            }
            catch (Exception ex)
            {
                throw new BSLException("AddAccount event occurs an error.[" + ex.Message + "]", ex, true);
            }
        }