public void AddPlayer(Card card, CardPlayer cardPlayer) { var existing = card.CardPlayers.SingleOrDefault(x => x.Id.Equals(cardPlayer.Id)); if (existing != null) { // have anything of importance changed? if (existing.TeeType != cardPlayer.TeeType && existing.RoundHandicap == cardPlayer.RoundHandicap) { // re-calculate existing.RoundHandicap = GetRoundHandicap(existing.Player, cardPlayer.TeeType); existing.TeeType = cardPlayer.TeeType; } else if (existing.RoundHandicap != cardPlayer.RoundHandicap) { existing.RoundHandicap = cardPlayer.RoundHandicap; existing.TeeType = cardPlayer.TeeType; } } else { // new if (!cardPlayer.RoundHandicap.HasValue) { cardPlayer.RoundHandicap = GetRoundHandicap(cardPlayer.Player, cardPlayer.TeeType); } card.CardPlayers.Add(cardPlayer); } }
public CardPlayerScore(CardPlayer cardPlayer) { Id = Guid.NewGuid(); this.CardPlayer = cardPlayer; }