示例#1
0
        public async Task <IActionResult> GetNearDrivers(LatLonDto latLonDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var drivers = await _locationRepository.GetNear(latLonDto.Latitude, latLonDto.Longitude);

            var driverLocationToReturn = new List <DriverLocationDto>();

            foreach (var driver in drivers)
            {
                var place = Helpers.Location.PointToPlaceDto(driver.Location);
                driverLocationToReturn.Add(new DriverLocationDto()
                {
                    DriverId  = driver.Id,
                    Latitude  = place.Latitude,
                    Longitude = place.Longitude
                });
            }


            return(Ok(driverLocationToReturn));
        }
示例#2
0
        public async Task GetNearDrivers(double lat, double lon)
        {
            var drivers = await _locationRepository.GetNear(lat, lon);

            var driverLocationToReturn = new List <DriverLocationDto>();

            foreach (var driver in drivers)
            {
                var place = Helpers.Location.PointToPlaceDto(driver.Location);
                driverLocationToReturn.Add(new DriverLocationDto()
                {
                    DriverId  = driver.Id,
                    Latitude  = place.Latitude,
                    Longitude = place.Longitude
                });
            }
            await Clients.Client(Context.ConnectionId).SendAsync("nearDrivers", driverLocationToReturn);
        }