public void Update(TradeBot bot)
 {
     _connection.GetConnection().Execute(
         "UPDATE TradeBots " +
         "SET [Name] = @name, [BotGroupId] = @groupId, [SetupDate] = @setupDate, [MonthlyFee] = @monthlyFee, [AuthorizationToken] = @authorizationToken, [Running] = @running " +
         "FROM TradeBots tb " +
         "WHERE botId = @id",
         bot,
         _connection.GetTransaction()
         );
 }
        private void UpdateForCardsYouGive(TradeBot bot, IEnumerable<MagicCard> youGive, Trade trade)
        {
            using (IConnection connection = Connection.NewConnection())
            {
                connection.BeginTransaction();
                foreach (var mCard in youGive)
                {
                    var magicCard = mCard;

                    Logger.Trace("You give - " + magicCard + " OwnedAmount: " + magicCard.OwnedAmount);
                    magicCard.OwnedAmount -= magicCard.CopiesOfCard;
                    magicCard.Save(connection);

                    var botCard = _cardRepository.GetCardForBot(bot.Id, magicCard.Id);
                    botCard.OwnedAmount -= magicCard.CopiesOfCard;
                    botCard.Save(connection);

                    var detail = new TradeDetail
                        {
                            Buying = false,
                            CardId = magicCard.Id,
                            NumberOfCard = magicCard.CopiesOfCard,
                            Price = magicCard.SellPrice
                        };

                    detail.Save(connection);
                }

                connection.CommitTransaction();
            }
        }
        private void UpdateForCardsYouGet(TradeBot bot, Trade trade, IEnumerable<MagicCard> youGet)
        {
            using (IConnection connection = Connection.NewConnection())
            {
                connection.BeginTransaction();

                foreach (var mCard in youGet)
                {
                    var magicCard = mCard;

                    var card = _cardRepository.Get(magicCard);
                    Logger.Trace("You get - " + magicCard + " OwnedAmount: " + card.OwnedAmount);
                    card.OwnedAmount += magicCard.CopiesOfCard;
                    card.Save(connection);

                    var botCard = _cardRepository.GetCardForBot(bot.Id, magicCard.Id);
                    if (botCard == null)
                    {
                        botCard = new BotCard {BotId = bot.Id, CardId = magicCard.Id};
                        botCard.Save(connection);
                        botCard.OwnedAmount = 0;
                    }

                    botCard.OwnedAmount += magicCard.CopiesOfCard;
                    botCard.Save(connection);

                    var detail = new TradeDetail
                        {
                            Buying = true,
                            CardId = magicCard.Id,
                            NumberOfCard = magicCard.CopiesOfCard,
                            Price = magicCard.BuyPrice,
                            TradeId = trade.TradeId
                        };

                    detail.Save(connection);
                }

                connection.CommitTransaction();
            }
        }