public async Task <MazeDataResponseModel> GetMazeData(MazeRequestModel mazeRequestModel) { var response = await httpClient.PostAsync(ponyApiUri, new StringContent( JsonConvert.SerializeObject(mazeRequestModel).ToString(), Encoding.UTF8, "application/json" )); var responseContent = await response.Content.ReadAsStringAsync(); var mazeId = JsonConvert.DeserializeObject <MazeResponseModel>(responseContent).MazeId; if (!mazes.ContainsKey(mazeId)) { var mazeDataResponse = await httpClient.GetAsync($"{ponyApiUri}/{mazeId}"); var mazeDataResponseContent = await mazeDataResponse.Content.ReadAsStringAsync(); var mazeDataResponseModel = JsonConvert.DeserializeObject <MazeDataResponseModel>(mazeDataResponseContent); mazeDataResponseModel.MazeId = mazeId; mazes.Add(mazeId, new MazeSolverHelper(mazeDataResponseModel)); return(mazeDataResponseModel); } return(mazes[mazeId].MazeData); }
public IActionResult Weight([FromBody] MazeRequestModel model) { var serviceModel = this.mapper.Map <MazeServiceModel>(model); var result = this.mazeService.GenerateWeightMaze(serviceModel); if (result == null) { return(this.BadRequest()); } return(this.Ok(result)); }
public async Task <MazeDataResponseModel> Post([FromBody] MazeRequestModel mazeRequestModel) { return(await mazeService.GetMazeData(mazeRequestModel)); }