コード例 #1
0
        public IHttpActionResult JoinGame(int id, GameJoinRequestModel model)
        {
            if (!ModelState.IsValid)
            {
                return this.BadRequest("Invalid game!");
            }

            var gameToJoin = this.games.GetById(id);

            if (this.User.Identity.GetUserId() == gameToJoin.RedUserId)
            {
                return this.BadRequest("The game is yours!");
            }

            var joinedGame = this.games.JoinGame(
                this.User.Identity.GetUserId(),
                model.Number,
                id);

            return this.Ok(new { result = string.Format("You joined game \"{0}\"", joinedGame) });
        }
コード例 #2
0
        public IHttpActionResult JoinGame(int id, GameJoinRequestModel model)
        {
            if (!ModelState.IsValid)
            {
                return(this.BadRequest("Invalid game!"));
            }

            var gameToJoin = this.games.GetById(id);

            if (this.User.Identity.GetUserId() == gameToJoin.RedUserId)
            {
                return(this.BadRequest("The game is yours!"));
            }

            var joinedGame = this.games.JoinGame(
                this.User.Identity.GetUserId(),
                model.Number,
                id);

            return(this.Ok(new { result = string.Format("You joined game \"{0}\"", joinedGame) }));
        }