示例#1
0
        public void Insert(IConvertedPokerHand convHand)
        {
            // Don't insert if null or hand contains no players
            if ((convHand != null) && (convHand.Players.Count > 0))
            {
                try
                {
                    if (!HandIsAlreadyInDatabase(convHand.Site, convHand.GameId))
                    {
                        bool successfullyUpdatedGameTable = UpdateGameTable(convHand);

                        if (successfullyUpdatedGameTable)
                        {
                            int handId = _databaseUtility
                                         .Use(_dataProvider)
                                         .GetIdentityOfLastInsertedHand();

                            // dd all active players in the hand to the Action Table
                            foreach (IConvertedPokerPlayer convPlayer in convHand)
                            {
                                int playerId = GetPlayerID(convHand, convPlayer);
                                UpdateActionTable(handId, playerId, convPlayer);
                            }
                        }
                    }
                }
                catch (Exception excep)
                {
                    Log.Error("Unexpected", excep);
                }
            }
        }
        /// <summary>
        /// Inserts Hand into database and returns the Id that was assigned to it
        /// </summary>
        /// <param name="convertedHand"></param>
        /// <returns>Id used in the identity column of the gamehhd table of the database</returns>
        public int?InsertHandAndReturnHandId(IConvertedPokerHand convertedHand)
        {
            _convertedPokerHandInserter
            .Use(_dataProvider)
            .Insert(convertedHand);

            return(_databaseUtility
                   .Use(_dataProvider)
                   .GetHandIdForHandWith(convertedHand.GameId, convertedHand.Site));
        }