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); }
public async Task <ActionResult> CreateLottoTicket(int id) { var user = await UserManager.FindValidByIdAsync(User.Identity.GetUserId()); if (user == null) { return(UnauthorizedModal()); } var lottoModel = await LottoReader.GetLottoItem(id); if (lottoModel == null) { return(View("~/Views/Modal/Invalid.cshtml")); } var balance = await BalanceReader.GetCurrencyBalance(User.Identity.GetUserId(), lottoModel.CurrencyId); if (balance == null) { return(View("~/Views/Modal/Invalid.cshtml")); } var model = user.GetTwoFactorModel <LottoPaymentModel>(TwoFactorComponent.Transfer); model.Balance = balance.Available; model.Symbol = lottoModel.Symbol; model.Name = lottoModel.Name; model.Description = lottoModel.Description; model.Rate = lottoModel.Rate; model.LottoItemId = lottoModel.LottoItemId; return(View("CreateLottoTicketModal", model)); }
public async Task <ActionResult> GetCurrencyBalance(int id) { var balanceModel = await BalanceReader.GetCurrencyBalance(User.Identity.GetUserId(), id); return(Json(new { CurrencyId = balanceModel.CurrencyId, Symbol = balanceModel.Symbol, MinTipAmount = balanceModel.MinTipAmount.ToString("F8"), Success = true, Balance = balanceModel.Available.ToString("F8"), })); }
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); }