private List <RoverModel> GetRoverList(MarsRoverRequestModel model) { var roverList = new List <RoverModel>(); foreach (var roverItem in model.Rovers) { var plateau = _plateauService.DrawPlateau(model.Plateau); var rover = _roverService.SetRoverOnPlateau(model.Plateau, new DeploymentPointModel(roverItem.DeploymentPoint.Direction.ToString()) { X = roverItem.DeploymentPoint.X, Y = roverItem.DeploymentPoint.Y }); var movements = roverItem.Movement.ToString() .ToCharArray() .Select(x => Enum.Parse <MovementAbility>(x.ToString())) .ToList(); rover.Movement.MovementList = movements; roverList.Add(_roverService.CalculateRoverMovement(rover, plateau)); } return(roverList); }
public object Post([FromBody] MarsRoverModel model) { var roverList = new List <Rover>(); foreach (var roverItem in model.Rovers) { var plateau = _roverService.DrawPlateau(model.Plateau); var rover = _roverService.SetRoverOnPlateau(model.Plateau, new DeploymentPoint(roverItem.DeploymentPoint.Direction.ToString()) { X = roverItem.DeploymentPoint.X, Y = roverItem.DeploymentPoint.Y }); var movements = roverItem.Movement .ToCharArray() .Select(x => Enum.Parse <MovingAbility>(x.ToString())) .ToList(); rover.Movement.MovementList = movements; roverList.Add(_roverService.CalculateRoverMovement(rover, plateau)); } return(roverList.Select(x => new DeploymentPointModel() { X = x.DeploymentPoint.X, Y = x.DeploymentPoint.Y, Direction = x.DeploymentPoint.Direction.ToString() })); }