示例#1
0
        public static void RunApplication(IUserInteraction userInteraction)
        {
            var userUnderstanding = new UserUnderstanding(userInteraction);

            string userInput = "";

            string[] greetingVariations = { "hello", "hi", "howdy" };

            // matches "Ello ello", "ello ello Ello" etc
            // as well as "HELLOO", "hellooooooooooo" etc
            string[] greetingMatchers = { "^ello( ello)*$", "^hello+$" };
            if (!userUnderstanding.ReadUserInput(ref userInput, greetingVariations, greetingMatchers))
            {
                return;
            }

            userInteraction.WriteConsoleLine("Hello and welcome! Are you here for an appointment?");
            string[] yesVariations = { "yes", "yup" };
            if (!userUnderstanding.ReadUserInput(ref userInput, yesVariations, null))
            {
                return;
            }

            string guestName = "";

            userInteraction.WriteConsoleLine("Lovely stuff. What is your full name?");
            string[] nameRegex = { "([a-zA-Z]+\\s*\\b){2,}" };
            if (!userUnderstanding.ReadUserInput(ref guestName, null, nameRegex))
            {
                return;
            }

            string employeeName = "";

            if (AppointmentManager.GetAppointment(ref employeeName, guestName))
            {
                userInteraction.WriteConsoleLine("You have an appointment with " + employeeName + ".\n Would you like to check in for this appointment?");
                if (userUnderstanding.ReadUserInput(ref userInput, yesVariations))
                {
                    AppointmentManager.CheckInAppointment();
                    userInteraction.WriteConsoleLine("You're all checked in! Please take a seat.");
                }
            }
            else
            {
                userInteraction.WriteConsoleLine("I'm afraid you don't have an appointment in the system.");
            }
        }
示例#2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            int appointmentID = Intent.GetIntExtra("AppointmentID", 0);

            if (appointmentID > 0)
            {
                appointment = AppointmentManager.GetAppointment(appointmentID);
            }

            SetContentView(Resource.Layout.Appointment);
            nameTextEdit  = FindViewById <EditText>(Resource.Id.NameText);
            notesTextEdit = FindViewById <EditText>(Resource.Id.NotesText);
            saveButton    = FindViewById <Button>(Resource.Id.SaveButton);

            cancelDeleteButton = FindViewById <Button>(Resource.Id.CancelDeleteButton);

            cancelDeleteButton.Text = (appointment.ID == 0 ? "Cancel" : "Delete");

            nameTextEdit.Text  = appointment.Name;
            notesTextEdit.Text = appointment.Notes;

            cancelDeleteButton.Click += (sender, e) => { CancelDelete(); };
            saveButton.Click         += (sender, e) => { Save(); };

            #region Android Date Picker

            dateDisplay = FindViewById <TextView>(Resource.Id.dateDisplay);
            pickDate    = FindViewById <Button>(Resource.Id.pickDate);

            pickDate.Click += delegate { ShowDialog(DATE_DIALOG_ID); };

            date = DateTime.Today;

            UpdateDisplay();

            #endregion
        }
 public Appointment GetAppointment(int id)
 {
     return(dal.GetAppointment(id));
 }