public ActionResult <NewGameResponse> NewGame([FromBody] NewPostBody value) { //validate input if (!NewGameValidation.IsBodyPostValid(value)) { return(BadRequest()); } //create token NewGameResponse response = new NewGameResponse(); response.Token = Guid.NewGuid().ToString(); //generate structure to save (map with mines) MineMatrix mineMatrix = new MineMatrix(value.Height, value.Width, value.Bombs, response.Token); //save structure in repository //it could be an interface for db, file or memcached MineRepository repository = new MineRepository(); repository.Save(mineMatrix); return(response); }
static public bool IsBodyPostValid(NewPostBody newPostBody) { return(newPostBody.Height >= 0 && newPostBody.Width >= 0 & newPostBody.Bombs >= 0); }