public bool JoinGame(JoinGameDto dto) { var player = Session.Get <PlayerModel>(dto.PlayerId); if (player == null) { return(false); } var game = Session.Get <GameModel>(dto.GameId); if (game == null) { return(false); } var gatheringCard = game.Cards.First(c => c.IsGatheringCard); if (gatheringCard.Players == null) { gatheringCard.Players = new List <PlayerModel>(); } gatheringCard.Players.Add(player); using (var transaction = Session.BeginTransaction()) { Session.Update(gatheringCard); transaction.Commit(); } return(true); }
public IHttpActionResult AddPlayerToCard(JoinGameDto dto) { var response = _gameRepository.JoinGame(dto); if (response) { return(Ok()); } return(BadRequest()); }