예제 #1
0
        public async Task <IActionResult> GetPath(string id, string start, string end)
        {
            if (string.IsNullOrEmpty(start) || string.IsNullOrEmpty(end))
            {
                return(BadRequest("'start' and/or 'end' parameters are required but missing"));
            }

            var map = await _mapRepository.GetById(id);

            if (map == null)
            {
                return(NotFound($"Map with id '{id}' was not found"));
            }

            var path = _pathAlgorithm.Find(map, start, end);

            if (path == null)
            {
                return(Content("null", "application/json")); // Ok(null) would result in 204 No Content which may be more correct but doesn't comply with the specs.
            }

            var result = ToResultDto(path);

            return(Ok(result));
        }