ArmedCards.BusinessLogic.AppServices.Game.Join.Execute C# (CSharp) Method

Execute() public method

Join a game
public Execute ( Int32 gameID, Entities user, String passphrase, Entities playerType ) : Entities.JoinResponse
gameID System.Int32 The id of the game to join
user Entities The current user
passphrase String The passphrase for the game
playerType Entities Type of player joining
return Entities.JoinResponse
        public Entities.JoinResponse Execute(Int32 gameID, Entities.User user, String passphrase,
                                            Entities.Enums.GamePlayerType playerType)
        {
            Entities.Filters.Game.Select filter = new Entities.Filters.Game.Select();
            filter.GameID = gameID;
            filter.DataToSelect |= Entities.Enums.Game.Select.Rounds;
            filter.DataToSelect |= Entities.Enums.Game.Select.GamePlayerCards;

            Entities.Game game = _selectGame.Execute(filter);

            Entities.JoinResponse response = _joinGame.Execute(game, user, passphrase,playerType);

            if (response.Game != null)
            {
                if (response.Game.IsWaiting() &&
                        response.Result.HasFlag(Entities.Enums.Game.JoinResponseCode.SuccessfulAlreadyPlayer) == false)
                {
                    _sendMessage.UpdateWaiting(response.Game, true);
                }
                else if (response.Result.HasFlag(Entities.Enums.Game.JoinResponseCode.NewRoundStart) == true)
                {
                    _sendMessage.UpdateGame(response.Game, true);
                }
                else
                {
                    _sendMessage.UpdateLobby(response.Game, true);
                }
            }

            return response;
        }