public ServiceResult <PreTransferOM> PreTransfer(PreTransferIM im) { return(new ServiceResult <PreTransferOM> { Data = new TransferComponent().PreTransfer(this.GetUser(), im) }); }
public PreTransferOM PreTransfer(UserAccount account, PreTransferIM im) { var toAccount = new UserAccountDAC().GetByCountryIdAndCellphone(im.ToCountryId, im.ToCellphone); if (toAccount == null) { throw new CommonException(ReasonCode.ACCOUNT_NOT_EXISTS, MessageResources.AccountNotExist); } if (account.Id == toAccount.Id) { throw new CommonException(ReasonCode.TRANSFER_TO_SELF, MessageResources.TransferToSelf); } var country = new CountryComponent().GetById(im.ToCountryId); var profile = new UserProfileAgent().GetUserProfile(toAccount.Id); var cryptoCurrency = new CryptocurrencyDAC().GetById(im.CoinId); var fromWallet = new UserWalletComponent().GetUserWallet(account.Id, im.CoinId); return(new PreTransferOM { ToAvatar = toAccount.Photo ?? Guid.Empty, ToAccountName = country.PhoneCode + " " + toAccount.Cellphone, ToFullname = profile == null ? "" : ("* " + profile.LastName), IsTransferAbled = !toAccount.IsAllowTransfer.HasValue || toAccount.IsAllowTransfer.Value, IsProfileVerified = toAccount.L1VerifyStatus == VerifyStatus.Certified, CoinId = cryptoCurrency.Id, CoinCode = cryptoCurrency.Code, MinCount = ((decimal)Math.Pow(10, -cryptoCurrency.DecimalPlace)).ToString("G"), CoinDecimalPlace = cryptoCurrency.DecimalPlace.ToString(), CoinBalance = (fromWallet == null ? "0" : fromWallet.Balance.ToString(cryptoCurrency.DecimalPlace)), FiatCurrency = account.FiatCurrency, Price = (GetExchangeRate(account.CountryId, account.FiatCurrency, cryptoCurrency.Code)).ToString(), ChargeFee = "0" }); }