Exemplo n.º 1
0
        public override async Task <SkillResponse> HandleIntent(SkillRequest skillRequest, IntentRequest intentRequest,
                                                                ILambdaContext context)
        {
            var user = await _userStorageService.GetAsync(skillRequest.Context.System.User.UserId);

            var deviceSlotIndex = int.Parse(intentRequest.Intent.Slots["DeviceSlot"].Value);
            var foundDevice     = user.AvailableDevices.FirstOrDefault(x => x.Index == deviceSlotIndex);

            if (foundDevice == null)
            {
                return(TellWithoutEnding($"Could not find device with index {deviceSlotIndex}"));
            }

            await SpotifyClient.TransferPlaybackAsync(foundDevice.Id, true);

            user.CurrentPlayingDevice = foundDevice;
            await _userStorageService.SaveAsync(user);

            return(TellWithoutEnding($"Playing on {foundDevice.Name} now"));
        }