public IHttpActionResult GetDistance(int?destinationId, int?departureId) { if (!departureId.HasValue || !destinationId.HasValue) { throw new HttpResponseException(HttpStatusCode.BadRequest); } var planets = planetRepository.GetPlanetsByIdRaw(departureId ?? (int)InvalidPropertyValues.undefinedValue, destinationId ?? (int)InvalidPropertyValues.undefinedValue); if (planets.Count != 2) { throw new HttpResponseException(HttpStatusCode.NotFound); } var distance = FlightPath.FindDistance(planets[0], planets[1]); return(Ok(distance)); }