/// <summary> /// Update a handPlayer blind bet. /// </summary> /// <param name="handPlayerId">the handPlayer Id</param> /// <param name="blind">The new blind bet</param> /// <returns>True if the update was successful</returns> public bool UpdateHandPlayer_Blind(long handPlayerId, int blind) { int entitiesWritten; using (Bol_Model_DBEntities ctx = new Bol_Model_DBEntities()) { HandPlayer hpl = ctx.HandPlayers.Find(handPlayerId); hpl.Blind = blind; entitiesWritten = ctx.SaveChanges(); } return(IsSuccessfulUpdate(entitiesWritten)); }
/// <summary> /// Update a handPlayer's second hold card. /// </summary> /// <param name="handPlayerId">The handPlayer Id</param> /// <param name="holdCard2">The second hold card</param> /// <returns>True if the update was successful</returns> public bool UpdateHandPlayer_Hc2(long handPlayerId, short holdCard2) { int entitiesWritten; using (Bol_Model_DBEntities ctx = new Bol_Model_DBEntities()) { HandPlayer hpl = ctx.HandPlayers.Find(handPlayerId); hpl.HoldCard2 = holdCard2; entitiesWritten = ctx.SaveChanges(); } return(IsSuccessfulUpdate(entitiesWritten)); }
/// <summary> /// Insert a row representing a handPlayer (a specific player in a specific hand) into the database. /// </summary> /// <param name="handId">The hand Id</param> /// <param name="playerId">The player Id</param> /// <param name="chipCountStart">The player's chip count when the hand started (before antes and blinds)</param> /// <param name="blind">The blind the player paid for this hand</param> /// <param name="holdCard1">The player's first hold card</param> /// <param name="holdCard2">The player's second hold card</param> /// <param name="errorMessagesTextBox">The textbox for logging erros</param> /// <returns>The handPlayer Id</returns> public long InsertHandPlayer(long handId, int playerId, int chipCountStart, int blind, short holdCard1, short holdCard2, TextBox errorMessagesTextBox) { // Create a handPlayer object to insert into the database HandPlayer handPlayer = new HandPlayer { HandId = handId, PlayerId = playerId, ChipCountStart = chipCountStart, Blind = blind, HoldCard1 = holdCard1, HoldCard2 = holdCard2 }; using (Bol_Model_DBEntities ctx = new Bol_Model_DBEntities()) { try { ctx.HandPlayers.Add(handPlayer); int numRecordsWritten = ctx.SaveChanges(); // Check for errors if (numRecordsWritten != 1) { // ctx.SaveChanges() returns the number of records written to the DB. This method only writes one record at a time so if // the number of records written is != 1 there was a problem WriteErrorMessage("Wrong number of records written inside InsertHandPlayer. " + numRecordsWritten + " Records Written", errorMessagesTextBox); } } catch (System.Data.Entity.Infrastructure.DbUpdateConcurrencyException ex) { WriteErrorMessage("DbUpdateConcurrencyException inside InsertHandPlayer. " + ex.Message, errorMessagesTextBox); } catch (Exception ex) { WriteErrorMessage("Some unexpected exception occured inside InsertHandPlayer. " + ex.Message, errorMessagesTextBox); } } return(handPlayer.Id); }