public static async Task <CornTx> DebitWithdrawTx(string txId, User user, WalletServer server, decimal amount, BitcornContext dbContext, string platform)
        {
            if (user.UserWallet.Balance >= amount)
            {
                var sql = new StringBuilder();
                sql.Append(TxUtils.ModifyNumber(nameof(UserWallet), nameof(UserWallet.Balance), amount, '-', nameof(UserWallet.UserId), user.UserId));
                sql.Append(TxUtils.ModifyNumber(nameof(WalletServer), nameof(WalletServer.ServerBalance), amount, '-', nameof(WalletServer.Id), server.Id));
                await dbContext.Database.ExecuteSqlRawAsync(sql.ToString());

                var log = new CornTx();
                log.BlockchainTxId = txId;
                log.Amount         = amount;
                log.Timestamp      = DateTime.Now;
                log.TxType         = "$withdraw";
                log.TxGroupId      = Guid.NewGuid().ToString();
                log.Platform       = platform;
                log.ReceiverId     = user.UserId;
                dbContext.CornTx.Add(log);
                await dbContext.SaveAsync();

                return(log);
            }
            return(null);
        }
        static async Task CreateCornaddyInternal(BitcornResponse cornResponse, BitcornContext dbContext, WalletServer walletServer, UserWallet userWallet, string accessToken)
        {
            using (var client = new WalletClient(walletServer.Endpoint, accessToken))
            {
                var response = await client.GetNewAddressAsync("main");

                if (!response.IsError)
                {
                    var address = response.GetParsedContent();
                    userWallet.CornAddy     = address;
                    userWallet.WalletServer = walletServer.Index;

                    cornResponse.WalletObject = address;
                    await dbContext.SaveAsync();
                }
                //we got an error, fetch the internal wallet error code and figure out what to do
                else
                {
                    //get wallet error response
                    //var error = response.GetError();
                    cornResponse.WalletAvailable = false;
                }
            }
        }
        public static async Task <CornTx> DebitWithdrawTx(string cornaddy, string txId, User user, WalletServer server, decimal amount, BitcornContext dbContext, string platform, int emptyUser)
        {
            if (user.UserWallet.Balance >= amount)
            {
                var sql = new StringBuilder();
                sql.Append(TxUtils.ModifyNumber(nameof(UserWallet), nameof(UserWallet.Balance), amount, '-', nameof(UserWallet.UserId), user.UserId));
                sql.Append(TxUtils.ModifyNumber(nameof(WalletServer), nameof(WalletServer.ServerBalance), amount, '-', nameof(WalletServer.Id), server.Id));
                await DbOperations.ExecuteSqlRawAsync(dbContext, sql.ToString());

                var log = new CornTx();
                log.BlockchainTxId = txId;
                log.Amount         = amount;
                log.Timestamp      = DateTime.Now;
                log.TxType         = "$withdraw";
                log.TxGroupId      = Guid.NewGuid().ToString();
                log.Platform       = platform;
                log.ReceiverId     = emptyUser;
                log.SenderId       = user.UserId;
                log.CornAddy       = cornaddy;

                var price = log.UsdtPrice = await ProbitApi.GetCornPriceAsync(dbContext);

                log.TotalUsdtValue = price * amount;
                dbContext.CornTx.Add(log);
                await dbContext.SaveAsync();

                return(log);
            }
            return(null);
        }