public async Task <IActionResult> Subscriptions([FromBody] decimal price) { var statusMessage = "Your subscription has not been activated."; 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 isPaidSubscription = subscriptions.Paid; if (!string.IsNullOrWhiteSpace(subscriptions.Address) && !subscriptions.Paid) { switch (subscriptions.WalletType) { case WalletType.Electrum: { isPaidSubscription = _bitcoinService.CheckEqualsBalance(subscriptions.Address, price); break; } case WalletType.Ethereum: { var balance = await _ethereumService.GetBalance(subscriptions.Address); isPaidSubscription = price <= Nethereum.Util.UnitConversion.Convert.FromWei(balance.Value); break; } } if (isPaidSubscription) { var expireInDays = DateTime.Now.AddDays(Convert.ToInt32(_configuration["Subscription:ExpireInDays"])); await _subscriptionsRepository.PaidToAddress(expireInDays, subscriptions.Id); await _emailSender.SendEmailAsync(_configuration["EmailNotifcation"], "Notification:", $"New user {user.Email} subscripe on the safecryptotrades."); statusMessage = "Your subscription successfully activated."; } } return(new JsonResult(new { Status = isPaidSubscription, StatusMessage = statusMessage })); }