public async Task <IActionResult> GenerateSubscribeAddress([FromBody] SubscribeModel model) { if (!System.Enum.IsDefined(typeof(WalletType), model.WalletType)) { return(BadRequest($"Wrong wallet type with value '{model.WalletType}'.")); } var user = await _userManager.GetUserAsync(User); if (user == null) { throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'."); } var subscriptions = await _subscriptionsRepository.GetByUserId(user.Id); var price = Convert.ToDecimal(_configuration["Subscription:" + model.WalletType + ":Price"]); var address = string.Empty; switch (model.WalletType) { case WalletType.Electrum: { address = _bitcoinService.GenerateAddress(subscriptions.Id, _configuration["Subscription:Electrum:ExtPubKey"]); break; } case WalletType.Ethereum: { var wallet = await _ethereumService.CreateAddress(subscriptions.Id, _configuration["Subscription:Ethereum:Words"], _configuration["Subscription:Ethereum:SeedPassword"]); address = wallet.Item1; break; } } await _subscriptionsRepository.SavePaymentAddress(address, model.WalletType, subscriptions.Id); return(new JsonResult(new { Address = address, Price = price })); }