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) })); }
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) }); }
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) })); }
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); }
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)); }