public string Create(NewTransaction tran) { var balance = _balanceRepository.GetById(tran.BalanceId); if (balance == null) { throw new ServiceException("Balance not found"); } var rate = _rateRepository.GetByCurrencies(tran.CurrencyId, balance.CurrencyId); if (tran.CurrencyId == balance.CurrencyId) { rate = new Rate { Val = 1 } } ; if (rate == null) { throw new ServiceException("Rate not found"); } var amount = tran.Amount * (decimal)rate.Val; if (tran.Type == (int)TransactionType.Withdraw) { CheckAmount(balance, amount); } tran.Amount = amount; return(_transactionRepository.Create(tran)); }