public Task <bool> DoesAccountHaveBalance(CashCard cashCard) { var result = _accountRepo.GetAccountBalance(cashCard.AccountNumber); if (result >= 0.5m) { return(Task.FromResult <bool>(true)); } else { return(Task.FromResult <bool>(false)); } }
public void BuyCan(CashCard cashCard) { if (isEmpty()) { throw new VendingMachineEmptyException(); } if (!cashCard.HasSufficientFundsFor(PriceOfCan)) { throw new InsufficientFundsException(); } cashCard.Deduct(PriceOfCan); if (isThreadSafe) { Interlocked.Decrement(ref _inventory); } else { _inventory--; } }
public Task <bool> Vend(CashCard cashCard, int PinNumber) { var isVendingSuccess = false; // No point proceeding if PIN is incorrect if (_cardManager.IsAuthorised(cashCard, PinNumber)) { var isVendingPossible = _inventoryManager.IsVendingPossible(); var doesAccHaveBalance = _accountManager.DoesAccountHaveBalance(cashCard); if (isVendingPossible.Result && doesAccHaveBalance.Result) { var updateAccount = _accountManager.UpdateAccount(cashCard); var updateInventory = _inventoryManager.UpdateInventory(); if (updateAccount && updateInventory) { isVendingSuccess = true; } } } return(Task.FromResult <bool>(isVendingSuccess)); }
public bool UpdateAccount(CashCard card) { throw new NotImplementedException(); }
public bool IsAuthorised(CashCard cashCard, int pin) { return(_cashCardRepo.IsAuthorised(cashCard.CardNumber, pin)); }