/// <inheritdoc/> public async Task <bool> DeleteSensorByIdAsync(int id) { var sensorFound = await _sensorContext.Sensors.FirstOrDefaultAsync(s => s.Id == id); if (sensorFound == null) { _logger.LogError(SensorsConstants.SENSOR_NOT_FOUND); return(false); } _sensorContext.Remove(sensorFound); await _recordService.DeleteAllRecordsBySensorIdAsync(sensorFound.Id); await _sensorContext.SaveChangesAsync(new CancellationToken()); await _sensorDeletedEventProducer.Publish(sensorFound.Id); return(true); }