Example #1
0
        private async Task ShowPerDiem(IDialogContext context, Location storloc)
        {
            string imageurl = await BingQuery.GetImageURL(storloc);

            HeroCard addcard = await CardController.AddressCard(storloc, imageurl);

            Attachment adattach = addcard.ToAttachment();
            var        cmessage = context.MakeMessage();

            cmessage.Attachments.Add(adattach);
            await context.PostAsync(cmessage);

            if (storloc.Address.CountryRegionIso2.ToLower().Contains("us"))
            {
                Double mealrate = await PQuery.GetMealLoc(storloc.Address);

                string drate  = String.Format("{0:C}", Convert.ToInt32(mealrate));
                string dtrate = String.Format("{0:C}", Convert.ToInt32((mealrate * .75)));
                await context.PostAsync($"Daily meal rate: Full Day - {drate} and Travel Day - {dtrate}");
            }
            else
            {
                await context.PostAsync("Sorry international locations are not currently supported for Per Diem!");
            }
        }
Example #2
0
        private async Task MessageReceivedAsync(IDialogContext context, IAwaitable <IMessageActivity> result)
        {
            var message = await result;

            if ((message.Text != null) && (message.Text.Trim().Length > 0))
            {
                Location sresult = await BingQuery.GetGeoLoc(message.Text);

                if (sresult != null)
                {
                    string imageurl = await BingQuery.GetImageURL(sresult);

                    HeroCard addcard = await CardController.AddressCard(sresult, imageurl);

                    Attachment adattach = addcard.ToAttachment();
                    var        cmessage = context.MakeMessage();
                    cmessage.Attachments.Add(adattach);
                    await context.PostAsync(cmessage);

                    context.UserData.SetValue <Location>("SelectedLocation", sresult);
                    await context.PostAsync("Is this the correct location: Yes/No?");

                    context.Wait(this.ValidateAddressAsync);
                }
                else
                {
                    --attempts;
                    if (attempts > 0)
                    {
                        await context.PostAsync("Sorry that search returned zero results, please try an address, City and State, or Postal Code:");

                        context.Wait(this.MessageReceivedAsync);
                    }
                    else
                    {
                        await context.PostAsync("Sorry you have tried too many times, returning to main menu!");

                        context.Fail(new TooManyAttemptsException("Too many attempts with incorrect adddress"));
                    }
                }
            }
            else
            {
                --attempts;
                if (attempts > 0)
                {
                    await context.PostAsync("Sorry you must enter something to search, try and address or City and State or just a postal code:");

                    context.Wait(this.MessageReceivedAsync);
                }
                else
                {
                    await context.PostAsync("Sorry you have tried too many times, returning to main menu!");

                    context.Fail(new TooManyAttemptsException("Error blank input"));
                }
            }
        }
Example #3
0
        private async Task AirportRange(IDialogContext context, Location storloc)
        {
            string imageurl = await BingQuery.GetImageURL(storloc);

            HeroCard addcard = await CardController.AddressCard(storloc, imageurl);

            Attachment adattach = addcard.ToAttachment();
            var        cmessage = context.MakeMessage();

            cmessage.Attachments.Add(adattach);
            await context.PostAsync(cmessage);

            List <airport> fports = await AirportFind.GetAirportsRange(storloc.Point.GetCoordinate().Latitude, storloc.Point.GetCoordinate().Longitude, 100);

            if (fports.Count > 0)
            {
                await context.PostAsync($"I found {fports.Count} airports: ");

                await CardController.AirportCards(fports, context, storloc);
            }
            else
            {
                List <airport> fportsext = await AirportFind.GetAirportsRange(storloc.Point.GetCoordinate().Latitude, storloc.Point.GetCoordinate().Longitude, 200);

                if (fportsext.Count > 0)
                {
                    await context.PostAsync($"I found {fportsext.Count} airports: ");

                    await CardController.AirportCards(fportsext, context, storloc);
                }
                else
                {
                    await context.PostAsync("Sorry I couldn't find an airport within 200 miles");
                }
            }
        }