Ejemplo n.º 1
0
        private async Task UpdateImpulsDataAsync(IImpulsDeviceDataRepository repository, VegaDevice device)
        {
            var lastUpdateTime = await repository
                                 .GetUptimeAsync(device.Id, _cancellationToken)
                                 .ConfigureAwait(false);

            var vegaServerLoadedData = await communicator
                                       .GetImpulsDeviceDataAsync(device.Eui, device.Id, lastUpdateTime, _cancellationToken)
                                       .ConfigureAwait(false);

            await repository
            .AddAsync(vegaServerLoadedData, _cancellationToken)
            .ConfigureAwait(false);
        }
        public async Task <ActionResult <VegaImpulsDeviceData> > PostVegaImpulsDeviceData(VegaImpulsDeviceData vegaImpulsDeviceData)
        {
            if (vegaImpulsDeviceData == null)
            {
                throw new ArgumentNullException(nameof(vegaImpulsDeviceData));
            }

            if (!_repository.DeviceExists(vegaImpulsDeviceData.DeviceId))
            {
                return(BadRequest());
            }

            await _repository.AddAsync(vegaImpulsDeviceData).ConfigureAwait(false);

            return(CreatedAtAction("GetImpulsDeviceData", new { id = vegaImpulsDeviceData.Id }, vegaImpulsDeviceData));
        }