public async Task <IActionResult> Post([FromBody] SensorTelemetryModel model)
        {
            // Validate model.

            // Convert to entity.
            var entity = new SensorTelemetryEntity
            {
                Id          = model.Id,
                Measurement = model.Measurement,
                Timestamp   = model.Timestamp
            };

            // Get Grain and process event.
            var sensor = grainFactory.GetGrain <ISensorTypeAIntakeGrain>(Guid.Parse(model.Id));
            var result = await sensor.RecordMeasurementAsync(entity);

            return(result
                                ? Ok()
                                : StatusCode(500));
        }
        private bool OnReceive(DeviceMessage data)
        {
            _count++;
            Console.WriteLine($"Device {_deviceId} received the {_count}th message");
            System.Diagnostics.Debug.WriteLine($"Device {_deviceId} received the {_count}th message");

            var message = JsonConvert.DeserializeObject <SensorTelemetry>(data.Message);
            var entity  = new SensorTelemetryEntity
            {
                PartitionKey = _deviceId,
                RowKey       = (long.MaxValue - DateTime.UtcNow.Ticks).ToString(),
                Humidity     = message.Humidity,
                Temperature  = message.Temperature
            };

            _tableStorage.Insert(entity, data.PartitionId);

            Sender.Tell(true);
            return(true);
        }