Пример #1
0
 private static bool IsTimeAdded(BookingForm state)
 {
     if (state.Date.TimeOfDay.TotalSeconds == 0)
     {
         return(true);
     }
     return(false);
 }
Пример #2
0
        private static Task <ValidateResult> ValidatePhNum(BookingForm state, object response)
        {
            var    result      = new ValidateResult();
            string phoneNumber = string.Empty;

            if (IsPhNum((string)response))
            {
                result.IsValid = true;
                result.Value   = response;
            }
            else
            {
                result.IsValid  = false;
                result.Feedback = "Make sure the phone number you entered are all numbers.";
            }
            return(Task.FromResult(result));
        }
Пример #3
0
        private static Task <ValidateResult> ValidateTime(BookingForm state, object response)
        {
            var result = new ValidateResult();
            var dt     = (DateTime)response;

            // Do the checks here whether the time is available.
            // Hard coded for demo purposes
            if (dt.ToString("HH:mm") == "20:30")
            {
                // If time not available
                result.IsValid  = false;
                result.Feedback = "Sorry, that time is not available! Times that are available are: 6.30pm, 7.00pm, 8.00pm, 9.00pm";
            }
            else
            {
                result.IsValid = true;
                result.Value   = response;
            }
            return(Task.FromResult(result));
        }
Пример #4
0
        private void SaveBooking(IDialogContext context, BookingForm bookingform)
        {
            var booking = new Booking();

            if (bookingform.Time != null)
            {
                // Time stated separately
                var time = bookingform.Time /*.GetValueOrDefault()*/;
                booking.BookingDateTime = bookingform.Date.Date.Add(time.TimeOfDay);
            }
            else
            {
                booking.BookingDateTime = bookingform.Date;
            }
            booking.Name      = bookingform.Name;
            booking.NumPeople = bookingform.NumPeople;
            booking.PhNum     = bookingform.PhNum;
            booking.Requests  = bookingform.Requests;
            context.UserData.SetValue <Booking>("booking", booking);
        }