public Card GetDiscardPile(string gameId, string playerId) { CardGame cardGame = cardGameRepository.GetCardGame(gameId); if (cardGame == null) { throw new NullReferenceException(); } else { Player player = cardGame.Players.First(player => player.Id == playerId); Card card = cardGame.GetDiscardPile(); player.Hand.Add(card); player.Stage = Stage.Discard; cardGameRepository.UpdateGame(cardGame); return(card); } }