public IActionResult Post([FromBody] CreateGameRequest newGame) { Player player = (Player)HttpContext.Items["Player"]; // Verify that everything is OK. int nrOfOngoingGames = player.races.Count; int nrofAllowedGames = 0; IConfiguration config = Config.GetConfiguration(player); int nrOfAllowedGames = config.GetMaxNrOfParalellGames(); if (player.races.Count > nrofAllowedGames) { return(new OkResult());// TODO:400 not allowed operation } // Add to repository. Race newRace = new Race(newGame.minNrOfPlayers, newGame.maxNrOfPlayers, player); bool opOk = raceRepo.Add(newRace); // Map to Race resource and send back to client. RaceResource race = new RaceResource { Id = newRace.Id }; //race.Relations.Add(Link.CreateLink("/v1/players")) return(new OkObjectResult(race)); }