Exemplo n.º 1
0
        private async Task <AlexaResponse> HandleWhoOwnsHouseIntent(AlexaRequest request, AlexaResponse response, bool mine)
        {
            string address = null;

            if (mine)
            {
                var zipCodes = await _zipCodeRepository.GetZipCodes();

                var deviceAddress = await GetDeviceAddress(request);

                if (!MyAddress(response, deviceAddress, zipCodes, ref address))
                {
                    return(response);
                }
            }
            else
            {
                var addressSlot = request.Request.Intent.Slots["address"].ToObject <AddressSlot>();
                address = addressSlot.Value;
            }

            var propertyInfo = await _pvaAddressLookup.GetPropertyInfo(address);

            if (!string.IsNullOrWhiteSpace(propertyInfo.Error))
            {
                response.Response.OutputSpeech.Text         += $"Sorry, I wasn't able to find the owner of {address}.";
                response.Response.Reprompt.OutputSpeech.Text = "Ask me another question. For help, just say help.";
                AddUnknownAddressCard(response, address);
                response.Response.ShouldEndSession = false;
                return(response);
            }

            var phoneticAddress = await _phoneticAddressHelper.GetPhoneticBaseAddress(propertyInfo.Address);

            response.Response.OutputSpeech.Text         += $"The owner of {phoneticAddress} is {propertyInfo.Address.Owner}.";
            response.Response.Reprompt.OutputSpeech.Text = "Ask me another question. For help, just say help.";
            AddAddressCard(response, propertyInfo.Address.AddressDisplay, propertyInfo);
            response.Response.ShouldEndSession = false;

            return(response);
        }