private async Task <WithdrawCurrencyModel> CreateWithdrawModel(Cryptopia.Entity.ApplicationUser user, WithdrawCurrencyModel model)
        {
            var currencyData = await CurrencyReader.GetCurrency(model.Symbol);

            var balanceData = await BalanceReader.GetCurrencyBalance(User.Identity.GetUserId(), currencyData.CurrencyId);

            var addressBook = await AddressBookReader.GetAddressBook(User.Identity.GetUserId(), currencyData.CurrencyId);

            var verificationData = await UserVerificationReader.GetVerificationStatus(User.Identity.GetUserId());

            var estimatedCoinNzd = await BalanceEstimationService.GetNZDPerCoin(currencyData.CurrencyId);

            model                  = user.GetTwoFactorModel(TwoFactorComponent.Withdraw, model);
            model.Name             = currencyData.Name;
            model.CurrencyId       = currencyData.CurrencyId;
            model.CurrencyType     = currencyData.Type;
            model.Symbol           = balanceData.Symbol;
            model.Balance          = balanceData.Available;
            model.Fee              = currencyData.WithdrawFee;
            model.WithdrawFeeType  = currencyData.WithdrawFeeType;
            model.MinWithdraw      = currencyData.WithdrawMin;
            model.MaxWithdraw      = currencyData.WithdrawMax;
            model.AddressBookOnly  = !user.IsUnsafeWithdrawEnabled;
            model.AddressBook      = addressBook;
            model.AddressType      = currencyData.AddressType;
            model.HasWithdrawLimit = verificationData.Limit > 0;
            model.WithdrawLimit    = verificationData.Limit;
            model.WithdrawTotal    = verificationData.Current;
            model.EstimatedCoinNZD = estimatedCoinNzd;
            model.Instructions     = currencyData.WithdrawInstructions;
            model.Message          = currencyData.WithdrawMessage;
            model.MessageType      = currencyData.WithdrawMessageType.ToString().ToLower();
            model.Decimals         = currencyData.CurrencyDecimals;
            return(model);
        }
        private async Task <bool> SendConfirmationEmail(Cryptopia.Entity.ApplicationUser user, string symbol, decimal amount, string address, int withdrawId, string confirmToken, AddressType addressType)
        {
            var cancelWithdrawToken = await GenerateUserTwoFactorTokenAsync(TwoFactorTokenType.WithdrawCancel, user.Id);

            var confirmlink = Url.Action("WithdrawConfirm", "Withdraw", new { userId = user.Id, code = confirmToken, withdrawid = withdrawId }, protocol: Request.Url.Scheme);
            var cancellink  = Url.Action("WithdrawCancel", "Withdraw", new { userId = user.Id, code = cancelWithdrawToken, withdrawid = withdrawId }, protocol: Request.Url.Scheme);

            if (addressType != AddressType.Standard)
            {
                address = address.Replace(":", $"</strong><br />{addressType}: <strong>");
            }
            return(await SendEmailAsync(EmailTemplateType.ConfirmWithdraw, withdrawId, user.Email, user.Id, user.UserName, withdrawId, symbol, amount, address, confirmlink, cancellink));
        }
Пример #3
0
        private async Task <TransferCurrencyModel> CreateTransferModel(Cryptopia.Entity.ApplicationUser user, TransferCurrencyModel model)
        {
            var currencyData = await CurrencyReader.GetCurrency(model.Symbol);

            var balanceData = await BalanceReader.GetCurrencyBalance(User.Identity.GetUserId(), currencyData.CurrencyId);

            var verificationData = await UserVerificationReader.GetVerificationStatus(User.Identity.GetUserId());

            var estimatedCoinNzd = await BalanceEstimationService.GetNZDPerCoin(currencyData.CurrencyId);

            model                  = user.GetTwoFactorModel(TwoFactorComponent.Transfer, model);
            model.Name             = currencyData.Name;
            model.CurrencyId       = currencyData.CurrencyId;
            model.Symbol           = balanceData.Symbol;
            model.Balance          = balanceData.Available;
            model.HasWithdrawLimit = verificationData.Limit > 0;
            model.WithdrawLimit    = verificationData.Limit;
            model.WithdrawTotal    = verificationData.Current;
            model.EstimatedCoinNZD = estimatedCoinNzd;
            return(model);
        }