public async Task InitATM() { await _aTMRepository.CreateAsync(new BankTransaction() { Amount = 10000, ATMAddress = "Prospekt Nauki 37", IsDebit = true, TransactionDate = DateTime.Now }); }
public async Task Withdraw(int amount, string address) { if (amount <= 0) { throw new ATMRateEqualZeroException("Amount cant be less or equals then zero"); } if (amount % 5 > 0) { throw new ATMNotEnoughMoneyException("Amount is incorrect"); } if (string.IsNullOrWhiteSpace(address)) { throw new ATMNotEnoughMoneyException("Address is incorrect"); } var totalAmount = _aTMRepository.All.Sum(x => x.Amount); if (totalAmount < amount) { throw new ATMNotEnoughMoneyException("Not enough money"); } await _aTMRepository.CreateAsync(new BankTransaction() { Amount = -amount, ATMAddress = address, IsDebit = false, TransactionDate = DateTime.Now }); }