public static IWithdrawStateMachine CreateStateMachine(IWithdraw withdraw) { var statemachine = default(IWithdrawStateMachine); switch (withdraw.State) { case WithdrawState.WaitVerify: statemachine = new WithdrawWaitVerifyStateMachine(withdraw); break; case WithdrawState.WaitSubmit: statemachine = new WithdrawWaitSubmitStateMachine(withdraw); break; case WithdrawState.Processing: statemachine = new WithdrawProcessingStateMachine(withdraw); break; case WithdrawState.Complete: statemachine = new WithdrawCompleteStateMachine(withdraw); break; case WithdrawState.Fail: statemachine = new WithdrawFailStateMachine(withdraw); break; case WithdrawState.Cancel: throw new WithdrawIsCanceledException(); default: throw new NotImplementedException(); } return statemachine; }
public AccountWithdrawResponse Withdraw(string accountNumber, decimal amount) { AccountWithdrawResponse response = new AccountWithdrawResponse(); response.Account = _accountRepository.LoadAccount(accountNumber); if (response.Account == null) { response.Success = false; response.Message = "The account number is not valid"; return(response); } //Iwithdraw local var IWithdraw withdrawRule = WithdrawRulesFactory.Create(response.Account.Type);// // where does the Account object conme from response = withdrawRule.Withdraw(response.Account, amount); if (response.Success) { _accountRepository.SaveAccount(response.Account); } return(response); }
public AccountWithdrawResponse Withdraw(string accountNumber, decimal amount) { AccountWithdrawResponse response = new AccountWithdrawResponse(); response.Account = _accountRepository.LoadAccount(accountNumber); if (response.Account == null) { response.Success = false; response.Message = "That the account number is not valid."; return(response); } else { response.Success = true; } IWithdraw withdrawRule = WithdrawRulesFactory.Create(response.Account.Type); response = withdrawRule.Withdraw(response.Account, amount); if (response.Success) { _accountRepository.SaveAccount(response.Account); } return(response); }
public AccountWithdrawResponse Withdraw(string accountNumber, decimal amount) { AccountWithdrawResponse accountWithdrawResponse = new AccountWithdrawResponse { Account = _accountRepository.LoadAccount(accountNumber) }; if (accountWithdrawResponse.Account == null) { accountWithdrawResponse.Success = false; accountWithdrawResponse.Message = "Error: Account number DNE"; return(accountWithdrawResponse); } IWithdraw withdraw = WithdrawRulesFactory.Create(accountWithdrawResponse.Account.Type); accountWithdrawResponse = withdraw.Withdraw(accountWithdrawResponse.Account, amount); if (accountWithdrawResponse.Success) { _accountRepository.SaveAccount(accountWithdrawResponse.Account); } return(accountWithdrawResponse); }
public AccountWithdrawResponse Withdraw(string accountNumber, decimal amount) { AccountWithdrawResponse response = new AccountWithdrawResponse(); response.Account = _accountRepository.LoadAccount(accountNumber); if (response.Account == null) { response.Success = false; Console.WriteLine($"{accountNumber} is not valid"); return(response); } else { response.Success = true; } IWithdraw withdrawRules = WithdrawRulesFactory.Create(response.Account.Type); response = withdrawRules.Withdraw(response.Account, amount); if (response.Success == true) { _accountRepository.SaveAccount(response.Account); } return(response); }
public AccountWithdrawReponse Withdraw(string accountNumber, decimal amount) { AccountWithdrawReponse response = new AccountWithdrawReponse(); response.Account = sgBankRepository.LoadAccount(accountNumber); if (response.Account == null) { response.Success = false; response.Message = $"{accountNumber} is not a valid account."; return(response); } else { response.Success = true; } IWithdraw withdrawRule = WithdrawRulesFactory.Create(response.Account.Type); response = withdrawRule.Withdraw(response.Account, amount); if (response.Success) { amount = response.Amount; sgBankRepository.SaveAccount(response.Account); } return(response); }
public AccountWithdrawResponse Withdraw(string accountNumber, decimal amount) { AccountWithdrawResponse response = new AccountWithdrawResponse(); response.Account = _accountRepository.LoadAccount(accountNumber); if (response.Account == null) { response.Success = false; response.Message = $"{accountNumber} is not a valid account."; return(response); } else { response.Success = true; } IWithdraw withdrawRule = DIContainer.Kernel.Get <IWithdraw>(response.Account.Type.ToString()); response = withdrawRule.Withdraw(response.Account, amount); if (response.Success) { _accountRepository.SaveAccount(response.Account); } return(response); }
public AccountsController( IDeposit deposit, IWithdraw withdraw, IClose close, IAccountsQueries accountsQueries) { if (deposit == null) { throw new ArgumentNullException(nameof(deposit)); } if (withdraw == null) { throw new ArgumentNullException(nameof(withdraw)); } if (close == null) { throw new ArgumentNullException(nameof(close)); } if (accountsQueries == null) { throw new ArgumentNullException(nameof(accountsQueries)); } this.deposit = deposit; this.withdraw = withdraw; this.close = close; this.accountsQueries = accountsQueries; }
public AccountWithdrawResponse Withdraw(int AccountID, decimal amount) { AccountWithdrawResponse response = new AccountWithdrawResponse(); response.Account = _accountRepository.LoadAccount(AccountID); if (response.Account == null) { response.Success = false; response.Message = $"{AccountID} is not a valid account"; } else { response.Success = true; } IWithdraw withdrawRule = WithdrawRulesFactory.Create(response.Account.Type); response = withdrawRule.Withdraw(response.Account, amount); if (response.Success) { _accountRepository.SaveAccount(response.Account); } return(response); }
public AccountWithdrawResponse Withdraw(string accountNumber, decimal amount) { AccountWithdrawResponse response = new AccountWithdrawResponse(); response.Account = _accountRepository.LoadAccount(accountNumber); if (response.Account == null) { response.Success = false; response.Message = $"{accountNumber}is an invalid account number"; } else { response.Success = true; } if (response.Success) { IWithdraw WithdrawRule = WithdrawRulesFactory.Create(response.Account.Type); response = WithdrawRule.Withdraw(response.Account, amount); _accountRepository.SaveAccount(response.Account); } return(response); }
public AccountWithdrawResponse Withdraw(string accountNumber, decimal amount) { AccountWithdrawResponse response = new AccountWithdrawResponse(); response.Account = _accountRepository.LoadAccount(accountNumber); if (response.Account == null) { response.Success = false; response.Message = $"{accountNumber} is not a valid account."; return(response); } //NRH NINJECT //IWithdraw withdrawRule = WithdrawRulesFactory.Create(response.Account.Type); IWithdraw withdrawRule = DIWithdrawRules.Create(response.Account.Type); response = withdrawRule.Withdraw(response.Account, amount); if (response.Success) { _accountRepository.SaveAccount(response.Account); } return(response); }
public ImmutableArray <CapitalGain> Process(IWithdraw withdraw) { var asset = GetAsset(withdraw.Asset); var withdrawnAsset = GetWithdrawnAsset(withdraw.Asset); withdrawnAsset.TransferPosition(asset, withdraw.Amount, withdraw.ApplyTime, withdraw); // we realize the fees return(GetFeeCapitalGains(withdraw).ToImmutableArray()); }
public void PremiumAccountWithdrawTests(string accountNumber, string name, decimal balance, AccountType accountType, decimal amount, decimal newBalance, bool expectedResult) { IWithdraw withdraw = WithdrawRulesFactory.Create(AccountType.Premium); Account account = new Account(); account.AccountNumber = accountNumber; account.Name = name; account.Balance = balance; account.Type = accountType; AccountWithdrawResponse response = withdraw.Withdraw(account, amount); Assert.AreEqual(expectedResult, response.Success); }
private IEnumerable <CapitalGain> GetFeeCapitalGains(IWithdraw withdraw) { return(GetAsset(withdraw.Asset) .DecrementAmount(withdraw.TransactionFee, withdraw) .Select(t => new CapitalGain { Asset = withdraw.Asset, BoughtTime = t.Time, Quantity = t.RemainingQuantity, SoldTime = withdraw.ApplyTime, Cost = t.CostPerUnit * t.RemainingQuantity, Proceed = 0, BoughtTag = "Withdraw Fee" })); }
public void FreeAccountWithdrawRuleTest(string accountNumber, string name, decimal balance, AccountType accountType, decimal amount, bool expectedResult) { FreeAccountWithdrawRule WithdrawRule = new FreeAccountWithdrawRule(); Account account = new Account(); IWithdraw withdraw = WithdrawRule; AccountType type = account.Type; account.AccountNumber = accountNumber; account.Type = accountType; account.Name = name; account.Balance = balance; AccountWithdrawResponse response = withdraw.Withdraw(account, amount); Assert.AreEqual(expectedResult, response.Success); }
public AccountWithdrawResponse Withdraw(string accountNumber, decimal amount) { AccountWithdrawResponse response = new AccountWithdrawResponse(); try { response.Account = _accountRepository.LoadAccount(accountNumber); } catch (Exception ex) { response.Success = false; response.Message = ex.Message; } if (response.Account == null) { response.Success = false; response.Message = $"Error: {accountNumber} is not a valid account number. "; return(response); } IWithdraw withdraw = WithdrawRulesFactory.Create(response.Account.Type); response = withdraw.Withdraw(response.Account, amount); if (response.Success) { try { _accountRepository.SaveAccount(response.Account); } catch (Exception ex) { response.Success = false; response.Message = ex.Message; } } return(response); }
public Accountant(IWithdraw nextHandler = null) { _nextHandler = nextHandler; }
public decimal Withdraw(IWithdraw account, decimal amount) { throw new NotImplementedException(); }
public FrontDesk(IWithdraw nextHandler = null) { _nextHandler = nextHandler; }
public WithdrawCompleteStateMachine(IWithdraw withdraw) { Check.Argument.IsNotNull(withdraw, "withdraw"); this._withdraw = withdraw; }
public FinancialAnalyst(IWithdraw nextHandler = null) { _nextHandler = nextHandler; }
public WithdrawWaitSubmitStateMachine(IWithdraw withdraw) { Check.Argument.IsNotNull(withdraw, "withdraw"); this._withdraw = withdraw; }
public int WithdrawMoney(IWithdraw withdraw) { return(withdraw.Withdraw()); }
public WithdrawProcessingStateMachine(IWithdraw withdraw) { Check.Argument.IsNotNull(withdraw, "withdraw"); this._withdraw = withdraw; }
public void SetNextWithdrawChain(IWithdraw c) { nexInChain = c; }
public void SetNextWithdrawChain(IWithdraw c) { Console.WriteLine("You cannot attach chain links to the end"); }