Пример #1
0
        public IActionResult GetNearestTo([FromQuery] Origin origin)
        {
            if (origin == null)
            {
                return(BadRequest());
            }

            var coordinate       = Mapper.Map <Service.Models.Coordinate>(origin);
            var locationEntities = _repository.GetAllLocations();

            if (locationEntities == null)
            {
                return(NotFound());
            }

            var locations = Mapper.Map <IEnumerable <Service.Models.Location> >(locationEntities);

            var destination = _locator.GetNearestTo(coordinate, locations);

            var result = Mapper.Map <Destination>(destination);

            return(Ok(result));
        }