public async Task <IActionResult> DepositFiat(DepositFiatViewModel model) { var user = await GetUser(required : true); var wallet = _walletProvider.GetFiat(model.Asset); var amount = wallet.StringToAmount(model.Amount.ToString()); if (amount <= 0) { this.FlashError("Amount must be greater then 0"); return(View(model)); } var decimals = _settings.Assets[model.Asset].Decimals; if (Utils.GetDecimalPlaces(model.Amount) > decimals) { this.FlashError($"Amount must have a maximum of {decimals} digits after the decimal place"); return(View(model)); } if (!wallet.HasTag(user.Id)) { wallet.NewTag(user.Id); wallet.Save(); } var tx = wallet.RegisterPendingDeposit(user.Id, amount); model.PendingTx = tx; model.Account = wallet.GetAccount(); wallet.Save(); // send email: deposit created await _emailSender.SendEmailFiatDepositCreatedAsync(user.Email, model.Asset, wallet.AmountToString(tx.Amount), tx.DepositCode, wallet.GetAccount()); return(View("DepositFiatCreated", model)); }
public async Task <IActionResult> DepositFiat(string asset) { var user = await GetUser(required : true); var model = new DepositFiatViewModel { User = user, Asset = asset, }; return(View(model)); }