public async Task <GetVehicleStatusQueryResult> Handle(GetVehicleStatusQuery query, CancellationToken cancellationToken) { var ping = await _pingService.GetRecentByAsync(query.VehicleId); var pingQueryResult = new GetVehicleStatusQueryResult(); if (ping.PingDate == null || ping.PingStatus == Service.Models.PingStatus.Disconnected) { pingQueryResult.VehiclePingModel = ping; pingQueryResult.VehiclePingModel.PingStatus = Service.Models.PingStatus.Disconnected; } else if ((DateTime.Now - ping.PingDate).TotalMinutes <= 2) { pingQueryResult.VehiclePingModel = ping; } else { pingQueryResult.VehiclePingModel = new Service.Models.VehiclePing() { VehicleId = query.VehicleId, PingStatus = Service.Models.PingStatus.Disconnected }; } return(pingQueryResult); }