public HttpResponseMessage MoveRover(RoverUpdateModel roverUpdateModel) { if (!ModelState.IsValid) { return(Request.CreateResponse(HttpStatusCode.BadRequest, $"Incorrect Data,please check your parameters!")); } //Check if rover exist First var roverModel = _roverService.GetRover(roverUpdateModel.Id); if (roverModel == null) { roverModel = _roverService.CreateRover(roverUpdateModel); } _roverService.SetPosition(roverModel.CurrentX, roverModel.CurrentY); _roverService.Process(roverUpdateModel.MovementInstruction); var finalRoverPosition = _roverService.RoverCurrentPosition(roverUpdateModel.Id); _roverService.UpdateRover(finalRoverPosition); return(Request.CreateResponse(HttpStatusCode.OK, $"Updated RoverId: { finalRoverPosition.Id} ,moved to :({finalRoverPosition.CurrentX}, { finalRoverPosition.CurrentY }){ finalRoverPosition.CurrentDirection}")); }