public static void SetProcessed(MySqlConnection connection, OTContract_Holding_OfferFinalized offerToAdd)
 {
     connection.Execute(@"UPDATE OTContract_Holding_OfferFinalized SET Processed = 1 WHERE OfferID = @offerID AND BlockchainID = @blockchainID", new
     {
         offerID      = offerToAdd.OfferID,
         blockchainID = offerToAdd.BlockchainID
     });
 }
        public static void InsertIfNotExist(MySqlConnection connection, OTContract_Holding_OfferFinalized model)
        {
            var count = connection.QueryFirstOrDefault <Int32>("SELECT COUNT(*) FROM OTContract_Holding_OfferFinalized WHERE OfferID = @offerID AND BlockchainID = @blockchainID", new
            {
                offerID      = model.OfferID,
                blockchainID = model.BlockchainID
            });

            if (count == 0)
            {
                connection.Execute(
                    @"INSERT INTO OTContract_Holding_OfferFinalized (OfferID, Timestamp,
BlockNumber, TransactionHash, Holder1, Holder2, Holder3, ContractAddress, GasUsed, Processed, Data, GasPrice, BlockchainID) VALUES(@OfferID, @Timestamp, @BlockNumber, @TransactionHash, @Holder1, @Holder2, @Holder3, @ContractAddress, @GasUsed, 0, @Data, @GasPrice, @BlockchainID)",
                    new
                {
                    model.OfferID,
                    model.Timestamp,
                    model.BlockNumber,
                    model.TransactionHash,
                    model.Holder1,
                    model.Holder2,
                    model.Holder3,
                    model.ContractAddress,
                    model.GasUsed,
                    model.Data,
                    model.GasPrice,
                    model.BlockchainID
                });

                foreach (var holder in new[] { model.Holder1, model.Holder2, model.Holder3 })
                {
                    if (connection.QuerySingle <Int32>(
                            "SELECT COUNT(*) FROM OtOffer_Holders WHERE OfferID = @OfferID AND Holder = @holder AND BlockchainID = @blockchainID",
                            new { OfferID = model.OfferID, holder = holder, blockchainID = model.BlockchainID }) == 0)
                    {
                        connection.Execute(
                            "INSERT INTO OtOffer_Holders(OfferID, Holder, IsOriginalHolder, BlockchainID) VALUES (@OfferID, @holder, @IsOriginalHolder, @BlockchainID)",
                            new
                        {
                            OfferID          = model.OfferID,
                            holder           = holder,
                            IsOriginalHolder = true,
                            BlockchainID     = model.BlockchainID
                        });
                    }
                }

                //   DiscordHelper.OfferCreated(model);
            }
        }