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