Пример #1
0
        /// <summary>
        /// Confirm the selection before moving on to Restaurant choice.
        /// </summary>
        /// <param name="sc">Waterfall Step Context.</param>
        /// <param name="cancellationToken">Cancellation Token.</param>
        /// <returns>Dialog Turn Result.</returns>
        private async Task <DialogTurnResult> ConfirmSelectionBeforeBooking(WaterfallStepContext sc, CancellationToken cancellationToken)
        {
            var state = await ConversationStateAccessor.GetAsync(sc.Context);

            var reservation = state.Booking;

            var tokens = new StringDictionary
            {
                { "FoodType", reservation.Category },
                { "ReservationDate", reservation.ReservationDate?.ToShortDateString() },
                { "ReservationDateSpeak", reservation.ReservationDate?.ToSpeakString(true) },
                { "ReservationTime", reservation.ReservationTime?.ToShortTimeString() },
                { "AttendeeCount", reservation.AttendeeCount.ToString() }
            };

            var cardData = new ReservationConfirmCard
            {
                Category        = reservation.Category,
                Location        = reservation.Location,
                ReservationDate = reservation.ReservationDate?.ToShortDateString(),
                ReservationTime = reservation.ReservationTime?.ToShortTimeString(),
                AttendeeCount   = reservation.AttendeeCount.ToString()
            };

            var replyMessage = ResponseManager.GetCardResponse(
                RestaurantBookingSharedResponses.BookRestaurantConfirmationPrompt,
                new Card("ReservationConfirmCard", cardData),
                tokens);

            return(await sc.PromptAsync(Actions.ConfirmSelectionBeforeBookingStep, new PromptOptions { Prompt = replyMessage }, cancellationToken));
        }
Пример #2
0
        /// <summary>
        /// Confirm the selection before moving on to Restaurant choice.
        /// </summary>
        /// <param name="sc">Waterfall Step Context.</param>
        /// <param name="cancellationToken">Cancellation Token.</param>
        /// <returns>Dialog Turn Result.</returns>
        private async Task <DialogTurnResult> ConfirmSelectionBeforeBookingAsync(WaterfallStepContext sc, CancellationToken cancellationToken)
        {
            var state = await ConversationStateAccessor.GetAsync(sc.Context, cancellationToken : cancellationToken);

            var reservation = state.Booking;

            if (state.IsAction)
            {
                return(await sc.NextAsync(cancellationToken : cancellationToken));
            }

            var tokens = new Dictionary <string, object>
            {
                { "FoodType", reservation.Category },
                { "ReservationDate", reservation.ReservationDate?.ToShortDateString() },
                { "ReservationDateSpeak", reservation.ReservationDate?.ToSpeakString(TemplateManager, true) },
                { "ReservationTime", reservation.ReservationTime?.ToShortTimeString() },
                { "AttendeeCount", reservation.AttendeeCount.ToString() }
            };

            var cardData = new ReservationConfirmCard
            {
                Category        = reservation.Category,
                Location        = reservation.Location,
                ReservationDate = reservation.ReservationDate?.ToShortDateString(),
                ReservationTime = reservation.ReservationTime?.ToShortTimeString(),
                AttendeeCount   = reservation.AttendeeCount.ToString()
            };

            var replyMessage = TemplateManager.GetCardResponse(
                RestaurantBookingSharedResponses.BookRestaurantConfirmationPrompt,
                new Card("ReservationConfirmCard", cardData),
                tokens);

            // Workaround. In teams, HeroCard will be used for prompt and adaptive card could not be shown. So send them separatly
            if (Channel.GetChannelId(sc.Context) == Channels.Msteams)
            {
                await sc.Context.SendActivityAsync(replyMessage, cancellationToken);

                replyMessage = null;
            }

            return(await sc.PromptAsync(Actions.ConfirmSelectionBeforeBookingStep, new PromptOptions { Prompt = replyMessage }, cancellationToken));
        }