Example #1
0
        public ActionResult <MazeVisualizerDTO> VisualizeMazeSolution(Guid userId, string algorithm, [FromBody] MazeFE maze)
        {
            _logger.LogInformation("GET request for {0} maze visualizer from user with id {1}\n\n", algorithm, userId.ToString());

            try
            {
                var accessToken = Request.Headers["Bearer"];
                var payload     = Authorize(accessToken);
            }
            catch (ApiException e)
            {
                return(Unauthorized(new UnauthorizedError(e.Message)));
            }

            try
            {
                MazeVisualizerDTO mazeVisualizerData = _mazeService.Visualize(maze, algorithm.ToUpper());
                return(Ok(mazeVisualizerData));
            }
            catch (ApiException e)
            {
                if (e.StatusCode == 400)
                {
                    return(BadRequest(new BadRequestError(e.Message)));
                }

                return(NotFound(new NotFoundError(e.Message)));
            }
        }