public PreDepositOM PreDeposit(UserAccount user, int cryptoId) { var dac = new UserWalletDAC(); var wallet = dac.GetByAccountId(user.Id, cryptoId) ?? new UserWalletComponent().GenerateWallet(user.Id, cryptoId); var coin = new CryptocurrencyDAC().GetById(cryptoId); if (string.IsNullOrEmpty(wallet.Address)) { var agent = new FiiiFinanceAgent(); var addressInfo = agent.CreateWallet(coin.Code, user.Id, AccountTypeEnum.User, user.Email, user.Cellphone); if (string.IsNullOrWhiteSpace(addressInfo.Address)) { throw new CommonException(ReasonCode.GENERAL_ERROR, Resources.FailedGenerateAddress); } wallet.Address = addressInfo.Address; wallet.Tag = addressInfo.DestinationTag; dac.UploadAddress(wallet.Id, wallet.Address, wallet.Tag); } return(new PreDepositOM { Address = wallet.Address, Tag = wallet.Tag, Code = coin.Code, NeedTag = coin.NeedTag }); }