public async Task <BaseDTO <bool> > Withdraw(int accountId, float amount) { var result = new BaseDTO <bool>(); var account = await _accountRepository.GetById(accountId); if (account == null) { result.AddError($"Account {accountId} not found"); return(result); } if (amount > account.Balance) { result.AddError("Insufficient balance."); return(result); } var accountType = await _accountTypeRepository.GetById(account.AccountTypeId); if (accountType.Type == AccountTypeEnum.DepositAccount) { if ((DateTime.UtcNow.Date - account.DateCreated.Date).TotalDays < accountType.DepositPeriodInDays) { result.AddError("Withdraw can be made only at maturity."); return(result); } } account.Balance -= amount; result.Data = await _accountRepository.Update(account); return(result); }
public AccountType GetById(int id) { return(_accountTypeRepository.GetById(id)); }
public AccountType GetById(int id) { return(_country.GetById(id)); }