コード例 #1
0
        public IHttpActionResult Put(int id, [FromBody] BaseGameRequestModel model)
        {
            var userId = this.User.Identity.GetUserId();

            if (!this.games.GameCanBeJoinedByUser(id, userId))
            {
                return(this.BadRequest("Game is yours"));
            }

            var joinedGame = this.games.JoinedGame(id, userId, model.Number);

            return(this.Ok(new { result = string.Format("You joined game \"{0}\"", joinedGame) }));
        }
コード例 #2
0
        public IHttpActionResult Put(int id, BaseGameRequestModel model)
        {
            var userId = this.User.Identity.GetUserId();
            if (!this.games.GameCanBeJoinedByUser(id, userId))
            {
                return this.BadRequest("This game is yours! Do you have two personalities?");
            }

            // TODO: add notification

            var joinedGame = this.games.JoinGame(id, model.Number, userId);

            return this.Ok(new { result = string.Format("You joined game \"{0}\"", joinedGame) });
        }
コード例 #3
0
        public IHttpActionResult Put(int id, BaseGameRequestModel model)
        {
            var userId = this.User.Identity.GetUserId();

            if (!this.games.GameCanBeJoinedByUser(id, userId))
            {
                return(this.BadRequest("This game is yours! Do you have two personalities?"));
            }

            // TODO: add notification

            var joinedGame = this.games.JoinGame(id, model.Number, userId);

            return(this.Ok(new { result = string.Format("You joined game \"{0}\"", joinedGame) }));
        }
コード例 #4
0
        public IHttpActionResult Guess(int id, BaseGameRequestModel model)
        {
            var userId = this.User.Identity.GetUserId();
            if (!this.games.CanMakeGuess(id, userId))
            {
                return this.BadRequest("Either you are not part of the game or it is not your turn!");
            }

            var newGuess = this.guesses.MakeGuess(id, model.Number, userId);

            var guessResult = this.guesses
                .GetGuessDetails(newGuess.Id)
                .ProjectTo<GuessDetailsResponseModel>()
                .FirstOrDefault();

            return this.Ok(guessResult);
        }
コード例 #5
0
        public IHttpActionResult Guess(int id, BaseGameRequestModel model)
        {
            var userId = this.User.Identity.GetUserId();

            if (!this.games.CanMakeGuess(id, userId))
            {
                return(this.BadRequest("Either you are not part of the game or it is not your turn!"));
            }

            var newGuess = this.guesses.MakeGuess(id, model.Number, userId);

            var guessResult = this.guesses
                              .GetGuessDetails(newGuess.Id)
                              .ProjectTo <GuessDetailsResponseModel>()
                              .FirstOrDefault();

            return(this.Ok(guessResult));
        }