private static void ReplaceSensorData(SensorDto sensorDto, VehicleSnapshot vehicleSnapshot) { var sensor = vehicleSnapshot.Sensors[sensorDto.Name]; if (sensorDto.Timestamp >= sensor.Timestamp) { vehicleSnapshot.Sensors[sensorDto.Name] = VehicleSensorData.Create(sensorDto); } }
public async Task AddAsync(VehicleSnapshot vehicleSnapshot) { await _client.CreateDatabaseIfNotExistsAsync(new Database { Id = DocumentDb.DatabaseId }); await _client.CreateDocumentCollectionIfNotExistsAsync(UriFactory.CreateDatabaseUri(DocumentDb.DatabaseId), new DocumentCollection { Id = DocumentDb.CollectionId }); var documentUri = UriFactory.CreateDocumentCollectionUri(DocumentDb.DatabaseId, DocumentDb.CollectionId); await _client.UpsertDocumentAsync(documentUri, vehicleSnapshot); }