예제 #1
0
        public async Task <IActionResult> UpdateDriverLocation([FromBody] LatLonDto latLon)
        {
            var driverId = Guid.Parse(User.Claims
                                      .FirstOrDefault(c => c.Type == Helpers.Constants.Strings.JwtClaimIdentifiers.DriverId)?.Value);
            var trip = _tripsRepo.GetTripByDriver(driverId);

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

            try
            {
                // Sending driver's position to the customer
                await _hubContext.Clients.Client(_usersRepository.GetCustomerById(trip.CustomerId).ConnectionId)
                .SendAsync("postGeoData", latLon.Latitude, latLon.Longitude);
            }
            catch
            {
            }

            return(NoContent());
        }