public async Task <IHttpActionResult> CreateActivationForDevice(string deviceId)
        {
            if (string.IsNullOrEmpty(deviceId))
            {
                return(BadRequest());
            }

            deviceId = deviceId.ToLower();
            return(Ok(await _activationService.Create(deviceId).ConfigureAwait(false)));
        }
Exemplo n.º 2
0
        public async Task <IHttpActionResult> Create(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                return(BadRequest());
            }
            id = id.ToLower();
            //create device in iot hub registry
            var registryManager = RegistryManager.CreateFromConnectionString(iotHubConnectionString);
            var device          = await registryManager.AddDeviceAsync(new Device(id)).ConfigureAwait(false);

            var activation = await _activationService.Create(device);

            return(CreatedAtRoute("GetDeviceById", new { id }, activation));
        }