Example #1
0
        public ActionResult <List <MazeDTO> > GetMazeById(Guid id)
        {
            _logger.LogInformation("GET request for maze with Id {0}\n\n", id);
            IDictionary <string, object> payload;

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

            MazeDTO retMazeDTO = _mazeService.GetMazeById(id, (string)payload["userId"]);

            if (retMazeDTO != null)
            {
                return(Ok(retMazeDTO));
            }

            return(NotFound(new NotFoundError("Maze with id " + id.ToString() + " not in database")));
        }