BackgroundTasks.LightControllerVoiceCommandService.ChangeSpecificLightStateAsync C# (CSharp) Method

ChangeSpecificLightStateAsync() private method

Handles the command to change the state of a specific light.
private ChangeSpecificLightStateAsync ( ) : System.Threading.Tasks.Task
return System.Threading.Tasks.Task
        private async Task ChangeSpecificLightStateAsync()
        {
            string name = _voiceCommand.Properties["name"][0];
            string state = _voiceCommand.Properties["state"][0];
            Light light = _lights.FirstOrDefault(x => 
                x.Name.Equals(name, StringComparison.OrdinalIgnoreCase));
            if (null != light)
            {
                await ExecutePhrase(light, state);
                var response = CreateCortanaResponse($"Turned {name} {state}.");
                await _voiceServiceConnection.ReportSuccessAsync(response);
            }
        }