Exemple #1
0
        public async Task <HttpResponseMessage> UpdateDeviceEnabledStatus(string deviceId, [FromBody] JObject request)
        {
            bool isEnabled;

            ValidateArgumentNotNullOrWhitespace("deviceId", deviceId);

            if (request == null)
            {
                return(GetNullRequestErrorResponse <bool>());
            }

            try
            {
                var property = request.Property("isEnabled");

                if (property == null)
                {
                    return(GetFormatErrorResponse <bool>("isEnabled", "bool"));
                }

                isEnabled = request.Value <bool>("isEnabled");
            }
            catch (Exception)
            {
                return(GetFormatErrorResponse <bool>("isEnabled", "bool"));
            }

            return(await GetServiceResponseAsync(async() =>
            {
                DeviceModel device = await _deviceLogic.UpdateDeviceEnabledStatusAsync(deviceId, isEnabled);
                return true;
            }));
        }