Beispiel #1
0
        /// <summary>
        /// Initialise the ReservationBooking object that we use to track progress.
        /// </summary>
        /// <param name="context">TurnContext.</param>
        /// <returns>New ReservationBooking.</returns>
        private ReservationBooking CreateNewReservationInfo()
        {
            var restaurantReservation = new ReservationBooking
            {
                // Default initialisation of reservation goes here
            };

            return(restaurantReservation);
        }
Beispiel #2
0
 private async Task RenderSelectedDateTimeMessage(ITurnContext context, ReservationBooking reservation)
 {
     var reply = context.Activity.CreateReply(RestaurantBookingSharedResponses.BookRestaurantDateTimeEcho, ResponseBuilder, new StringDictionary
     {
         { "Date", reservation.Date?.ToSpeakString(true) },
         { "Time", reservation.Time?.ToShortTimeString() }
     });
     await context.SendActivityAsync(reply);
 }
Beispiel #3
0
 private async Task RenderSelectedDateTimeMessageAsync(ITurnContext context, ReservationBooking reservation, CancellationToken cancellationToken)
 {
     var reply = TemplateManager.GenerateActivity(
         RestaurantBookingSharedResponses.BookRestaurantDateTimeEcho,
         new Dictionary <string, object>
     {
         { "Date", reservation.ReservationTime?.ToSpeakString(TemplateManager, true) },
         { "Time", reservation.ReservationTime?.ToShortTimeString() }
     });
     await context.SendActivityAsync(reply, cancellationToken);
 }
Beispiel #4
0
        /// <summary>
        /// Initializes the reservation instance with values found in the LUIS entities.
        /// </summary>
        private void UpdateReservationInfoFromEntities(ReservationBooking reservation, RecognizerResult recognizerResult)
        {
            if (recognizerResult == null)
            {
                return;
            }

            foreach (var entity in recognizerResult.Entities)
            {
                switch (entity.Key)
                {
                case LuisEntities.Cuisine:
                    reservation.Category = LuisEntityHelper.TryGetNormalizedValueFromListEntity(entity.Value);
                    break;

                case LuisEntities.City:
                    reservation.Location = LuisEntityHelper.TryGetValueFromEntity(entity.Value);
                    break;

                case LuisEntities.BuiltInDateTime:
                    var dateTimeEntity = LuisEntityHelper.TryGetDateTimeFromEntity(entity.Value, true);
                    if (dateTimeEntity != null)
                    {
                        reservation.Date = dateTimeEntity.Value;
                        reservation.Time = dateTimeEntity.Value;
                    }
                    else
                    {
                        var dateEntity = LuisEntityHelper.TryGetDateFromEntity(entity.Value, true);
                        if (dateEntity.HasValue)
                        {
                            reservation.Date = dateEntity.Value;
                        }
                        else
                        {
                            var timeEntity = LuisEntityHelper.TryGetTimeFromEntity(entity.Value, true);
                            if (timeEntity.HasValue)
                            {
                                reservation.Time = timeEntity.Value;
                            }
                        }
                    }

                    break;
                }
            }
        }
Beispiel #5
0
 public RestaurantBookingState()
 {
     Booking = new ReservationBooking();
     Cuisine = new List <FoodTypeInfo>();
     AmbiguousTimexExpressions = new Dictionary <string, string>();
 }