public async Task <GameCreateResponseModel> PostPuzzle() { GameCreateResponseModel result; try { result = await Game.CreateGame(new GameModel { CreatorUid = AppInfo.AppUser.UserId, CreateGameType = "A", Language = LogicHelper.GetLangString(puzzle.Language), Word = puzzle.Word, Photo = this.Photo }); if (result.Status == GameCreateStatus.Ok) { AppInfo.AppUser.TotalCreatedPuzzles++; wordEntered = false; NeedDisplayFinalyControl = true; OnPropertyChanged(nameof(NeedDisplayScrambledWordControl)); OnPropertyChanged(nameof(NeedDisplayFinalyControl)); } } catch { result = new GameCreateResponseModel(); result.Status = GameCreateStatus.PostError; result.GameId = String.Empty; } return(result); }
public IHttpActionResult Post(GameCreateModel game) { if (game == null || !ModelState.IsValid) { return(this.BadRequest("Invalid game format!")); } Game gameResult = this.games.Create( this.User.Identity.GetUserId(), game.Name, game.Number); var responseResult = new GameCreateResponseModel { Blue = "No blue player yet", DateCreated = gameResult.DateCreated, GameState = gameResult.GameState.ToString(), Id = gameResult.GameId, Name = gameResult.Name, Red = gameResult.RedUser.UserName }; return(this.Ok()); }
public IHttpActionResult Post(GameCreateModel game) { if (game == null || !ModelState.IsValid) { return this.BadRequest("Invalid game format!"); } Game gameResult = this.games.Create( this.User.Identity.GetUserId(), game.Name, game.Number); var responseResult = new GameCreateResponseModel { Blue = "No blue player yet", DateCreated = gameResult.DateCreated, GameState = gameResult.GameState.ToString(), Id = gameResult.GameId, Name = gameResult.Name, Red = gameResult.RedUser.UserName }; return this.Ok(); }