public void ProcessQueueMessage([QueueTrigger("%azure-queue-accessdata%")] string message, TextWriter log) { try { UserWalletManager userWalletManager = new UserWalletManager(); MailManager mailManager = new MailManager(); Notification notification = userWalletManager.GetNotification(message); var user = aspNetUserManager.GetById(notification.IdUser); var wallet = Task.Run(() => NethereumHelper.CreateUserWallet()).Result; user.TokenAddress = wallet.blobname; user.WalletAddress = wallet.walletaddress; aspNetUserManager.Update(user); MailMessage mailMessage = new MailMessage() { Body = notification.MailContent, Destination = user.Email, Subject = "Confirm your email" }; mailManager.SendAsync(mailMessage); } catch (Exception ex) { var messageException = telemetria.MakeMessageException(ex, System.Reflection.MethodBase.GetCurrentMethod().Name); telemetria.Critical(messageException); } }
public bool AutorizeCampaign(Guid idCampaign, string IdUser) { bool result = false; var campaign = GetById(idCampaign); var product = productRepository.FindById(campaign.PRODUCT_IdProduct); var userProduct = userRepository.FindById(product.AspNetUsers_Id); var user = userRepository.FindById(campaign.AspNetUser_Id); try { var balance = Task.Run(() => NethereumHelper.GetBalance(user.WalletAddress, true)).Result; if (balance >= product.Price) { var _createTransaction = AsyncHelpers.RunSync <CreateTransactionModel>(() => NethereumHelper.DoTransaction(IdUser, user.WalletAddress, userProduct.WalletAddress, ((Double)product.Price * (Double)100000000).ToString())); if (campaign != null && campaign.IdCampaign != Guid.Empty && _createTransaction != null && _createTransaction.hashTransaction.Length > 5) { campaign.CAT_CAMPAIGN_STATUS_IdStatus = (int)CatCampaignStatusEnum.Authorized; repository.Edit(campaign); TransactionsCaptEntity _transaction = new TransactionsCaptEntity() { Amount = _createTransaction.amount, HashFrom = _createTransaction.hashFrom, HashTo = _createTransaction.hashTo, HashTransaction = _createTransaction.hashTransaction, TRANSACTION_TYPE_IdTransactionType = 1, BlockDate = DateTimeHelper.CurrentDateTimeString(), Gas = "0", RegisterDate = DateTimeHelper.CurrentDateTimeString(), CAMPAIGN_IdCampaign = campaign.IdCampaign }; transactionCaptRepository.Add(_transaction); result = true; } } } catch (Exception e) { result = false; var messageException = telemetria.MakeMessageException(e, System.Reflection.MethodBase.GetCurrentMethod().Name); telemetria.Critical(messageException); } return(result); }