Exemple #1
0
        public ActionResult <Position> Post(IReadOnlyList <char> commands)
        {
            if (commands.Any(c => !_validCommands.Contains(c)))
            {
                return(BadRequest("Please use only F,B,L,R commands"));
            }

            try
            {
                return(_movementHandler
                       .HandleMovementCommands(commands.Select(c => (MovementCommand)c).ToList()));
            }
            catch (ObstacleEncounteredException e)
            {
                return(UnprocessableEntity($"An obstacle was encountered. Details: {e.Message}."));
            }
        }
Exemple #2
0
 public Position Move(IReadOnlyList <MovementCommand> movementCommands)
 {
     return(_movementHandler.HandleMovementCommands(movementCommands));
 }