Beispiel #1
0
        public async Task <IActionResult> Post([FromRoute(Name = "deviceId")] string deviceId, [FromBody] PostMeasurementsModel measurements)
        {
            _logger.LogInformation(String.Format("Recording Measurements for SerialNumber: {0}", deviceId));

            var watch = Stopwatch.StartNew();

            //check if maintanence mode
            if (await _measurementService.IsInMaintananceMode())
            {
                return(new StatusCodeResult(503));
            }

            var count = await _measurementService.RecordMeasurements(deviceId, measurements.Measurements);

            if (count != measurements.Measurements.Count)
            {
                return(BadRequest(string.Format("Not all measurements recorded. Recorded {0} of (1)", count, measurements.Measurements.Count)));
            }

            return(Ok(count));
        }