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