Exemple #1
0
        private async Task BookAppointment(IDialogContext context, AppointmentBookingQuery appointmentData)
        {
            var hospitalSearchService = HospitalSearchServiceFactory.Create();
            var hospitals             = hospitalSearchService.SearchByDoctorName(appointmentData.DoctorName);

            if (hospitals.Count == 0)
            {
                PromptDialog.Confirm(context, RetryBook,
                                     "I couldn't find this Doctor in my database. Do you wanna try again?",
                                     "It's not a valid option!");
            }
            else
            {
                var appointmentService       = AppointmentServiceFactory.Create();
                var appointmentBookingResult = appointmentService.TryBook(hospitals[0].Id, appointmentData.DoctorName, appointmentData.DesiredDateTime);
                if (appointmentBookingResult.Success)
                {
                    await ShowAppointmentConfirmation(context, appointmentData);

                    context.Done <object>(null);
                }
                else
                {
                    context.PrivateConversationData.SetValue("appointment", appointmentData);
                    ShowSuggestedDateTimes(context, appointmentBookingResult.SuggestedDateTimes);
                }
            }
        }
Exemple #2
0
        private async Task AfterSelectDoctor(IDialogContext context, IAwaitable <string> result)
        {
            var doctorName     = await result;
            var appoitmentData = new AppointmentBookingQuery {
                DoctorName = doctorName
            };
            var form = new FormDialog <AppointmentBookingQuery>(appoitmentData, BuildAppointmentBookingForm, FormOptions.PromptInStart);

            context.Call(form, AfterAppointmentScheduleFormFilled);
        }
Exemple #3
0
        private async Task AfterSelectHospital(IDialogContext context, IAwaitable <string> result)
        {
            var hospitalName = await result;
            var locais       = context.PrivateConversationData.GetValue <List <Hospital> >("hospitals");
            var doctors      = locais.First(x => x.Name == hospitalName).Doctors;

            if (doctors.Count > 1)
            {
                context.PrivateConversationData.SetValue("doctors", doctors);
                PromptDialog.Choice(context, AfterSelectDoctor, doctors.Select(x => x.Name).ToArray(), "Select a doctor");
            }
            else
            {
                var doctor      = doctors.First();
                var appointment = new AppointmentBookingQuery {
                    DoctorName = doctor.Name
                };
                var form = new FormDialog <AppointmentBookingQuery>(appointment, BuildAppointmentBookingForm, FormOptions.PromptInStart);
                context.Call(form, AfterAppointmentScheduleFormFilled);
            }
        }
Exemple #4
0
 private static async Task ShowAppointmentConfirmation(IBotToUser context, AppointmentBookingQuery appointmentData)
 {
     await context.PostAsync(
         $@"Okay! Your appointment has been booked to {appointmentData.DesiredDateTime.ToShortDateString()}
             at {appointmentData.DesiredDateTime.ToShortTimeString()} with {appointmentData.DoctorName}");
 }