Esempio n. 1
0
        private int SetAppointment(int userId, AppointmentGetResults app)
        {
            ServiceSetAppointmentResults result = Service.SetAppointment(app.ServiceId, 0, app.AppointmentDate, userId, app.CustomerId, app.AppointmentTypeId, app.CaseSubject, "", "", (List <int>)null,
                                                                         app.PreventAutoQueue, "");

            return(result.AppointmentId);
        }
Esempio n. 2
0
        private int RescheduleAppointment(int userId, AppointmentGetResults app)
        {
            ProcessRescheduleAppointmentResults result = Process.RescheduleAppointment(
                app.ProcessId,
                1,//cancelationReason
                app.ServiceId,
                app.AppointmentDate,
                userId,
                app.AppointmentTypeId,
                TreatmentPlan.PlanCancelationMethod.Undefined,
                app.CaseSubject,
                "",
                app.ExtRef,
                null,
                app.PreventAutoQueue,
                "",
                app.IsWalkIn,
                true,
                false,
                false,
                null,
                0,
                "",
                app.AppointmentDuration,
                null
                );

            return(result.AppointmentId);
        }
Esempio n. 3
0
        /// <summary>
        /// This method get an appoinment by id
        /// </summary>
        /// <returns></returns>
        public static AppointmentGetResults GetAppointmentById(int appointmentId)
        {
            AppointmentGetResults appoinment = new AppointmentGetResults();

            try
            {
                WebAppoinmentsClientLibrary.Appoinments _appoinmentLibray = new WebAppoinmentsClientLibrary.Appoinments();
                appoinment = _appoinmentLibray.GetAppoinment(appointmentId).AppointmentInformation;
            }
            catch (Exception)
            {
                throw;
            }
            return(appoinment);
        }
        /// <summary>
        /// This method create an Iform (form flow) for reschedule an appointement
        /// </summary>
        /// <returns></returns>
        public static IForm <ReservationReschedule> BuildForm()
        {
            //Instance of library for manage appoinments
            WebAppoinmentsClientLibrary.Appoinments appointmentLibrary = new WebAppoinmentsClientLibrary.Appoinments();
            #region On complete, process Order
            OnCompletionAsyncDelegate <ReservationReschedule> processOrder = async(context, state) =>
            {
                try
                {
                    Char     delimiter        = '.';
                    string[] arrayInformation = state.processIdServiceId.Split(delimiter);
                    int      processId        = Convert.ToInt32(arrayInformation[0]);
                    int      serviceId        = Convert.ToInt32(arrayInformation[1]);

                    string[] dateInformation = state.Date.Split(delimiter);
                    string   stringDate      = dateInformation[1];
                    //stringDate = stringDate.Replace("-", " ");
                    stringDate = Utilities.Util.GetDateWithOutTime(stringDate);
                    //Here I create the new date
                    string newDate = stringDate + " " + state.Hour;
                    string newDat2 = Utilities.Util.GetDateWithCorrectPositionOfTheMonth(newDate);
                    int    result  = 0;
                    try
                    {
                        result = AppoinmentService.RescheduleAppoinment(processId, newDat2, serviceId);
                    }
                    catch (Exception)
                    {
                        result = AppoinmentService.RescheduleAppoinment(processId, newDate, serviceId);
                    }
                    AppointmentGetResults _appointment = AppoinmentService.GetAppointmentById(result);
                    await context.PostAsync($"The appointment was rescheduled, Ticket: " + _appointment.QCode + _appointment.QNumber);
                }
                catch (Exception ex)
                {
                    await context.PostAsync(ex.Message.ToString());
                }
            };
            #endregion
            #region set language and create a container for form builder
            CultureInfo ci = new CultureInfo("en");
            Thread.CurrentThread.CurrentCulture   = ci;
            Thread.CurrentThread.CurrentUICulture = ci;
            var culture  = Thread.CurrentThread.CurrentUICulture;
            var form     = new FormBuilder <ReservationReschedule>();
            var yesTerms = form.Configuration.Yes.ToList();
            var noTerms  = form.Configuration.No.ToList();
            yesTerms.Add("Yes");
            noTerms.Add("No");
            form.Configuration.Yes = yesTerms.ToArray();
            return(form
                   #endregion
                   #region process and service ids
                   .Field(new FieldReflector <ReservationReschedule>(nameof(ReservationReschedule.processIdServiceId))
                          .SetType(null)
                          .SetDefine(async(state, field) =>
            {
                //Get the actual user state of the customer
                ACFCustomer customerState = new ACFCustomer();
                int customerIdState = 0;
                customerIdState = state._customerId;
                string personalIdState = string.Empty;
                //Instance of library for manage customers
                WebAppoinmentsClientLibrary.Customers customerLibrary = new WebAppoinmentsClientLibrary.Customers();
                //Instance of library for manage cases
                WebAppoinmentsClientLibrary.Cases caseLibrary = new WebAppoinmentsClientLibrary.Cases();
                //Here we will to find the customer by customer id or personal id
                Customer customer = null;
                if (!string.IsNullOrEmpty(customerIdState.ToString()))
                {
                    //Get the object ObjectCustomer and inside of this the object Customer
                    try
                    {
                        customer = customerLibrary.GetCustomer(customerIdState).Customer;
                    }
                    catch (Exception)
                    {
                        // throw; here we not send the exception beacuse we need to do the next method below
                    }
                }
                //If not found by customer id , we will try to find by personal id
                else
                {
                    int idType = 0;
                    //Get the object ObjectCustomer and inside of this the object Customer
                    try
                    {
                        customer = customerLibrary.GetCustomerByPersonalId(personalIdState, idType).Customer;
                    }
                    catch (Exception)
                    {
                        //throw;
                    }
                }
                if (customer == null)
                {
                    throw new Exception("No records found");
                }
                else
                {
                    //Declaration of Calendar Get Slots Results object
                    CalendarGetSlotsResults slotToShowInformation = new CalendarGetSlotsResults();
                    //Set the parameters for get the expected appoinments
                    int customerTypeId = 0;
                    string customerTypeName = "";
                    int customerId = customer.Id;
                    DateTime startDate = DateTime.Today;
                    //here we add ten days to the startdate
                    DateTime endDate = startDate.AddDays(10);
                    string fromDate = startDate.ToString();
                    string toDate = endDate.ToString();
                    string typeSeriaizer = "XML";
                    //Declaration of the ocject to save the result of the GetExpectedAppoinment
                    ObjectCustomerGetExpectedAppointmentsResults objectCustomerGetExpectedAppointmentsResults = new ObjectCustomerGetExpectedAppointmentsResults();
                    objectCustomerGetExpectedAppointmentsResults = customerLibrary.GetExpectedAppoinment(customerTypeId, customerTypeName, customerId, startDate, endDate, typeSeriaizer);
                    if (objectCustomerGetExpectedAppointmentsResults.ListCustomerGetExpectedAppointmentsResults.Count > 0)
                    {
                        foreach (CustomerGetExpectedAppointmentsResults listCustomer in objectCustomerGetExpectedAppointmentsResults.ListCustomerGetExpectedAppointmentsResults)
                        {
                            //At first I need to find the appoinment by appoiment id, for saw the actual status
                            Appointment appointment = appointmentLibrary.GetAppoinment(listCustomer.AppointmentId).AppointmentInformation;
                            string data = appointment.AppointmentDate.ToString();
                            string processIdAndServiceId = appointment.ProcessId + "." + appointment.ServiceId + "." + Utilities.Util.GetDateWithOutTime(data);
                            field
                            .AddDescription(processIdAndServiceId, data + " | " + listCustomer.ServiceName)              //here we put the process id and the date of the appointment of this process
                            .AddTerms(processIdAndServiceId, data + " | " + listCustomer.ServiceName);
                        }
                        return await Task.FromResult(true);
                    }
                    else
                    {
                        throw new Exception("No records found");
                    }
                }
            }))
                   #endregion
                   #region Date
                   .Field(new FieldReflector <ReservationReschedule>(nameof(ReservationReschedule.Date))
                          .SetType(null)
                          .SetDefine(async(state, field) =>
            {
                List <OTempus.Library.Class.Calendar> listCalendars;
                StringBuilder response = new StringBuilder();
                List <CalendarGetSlotsResults> listGetAvailablesSlots = new List <CalendarGetSlotsResults>();
                if (!String.IsNullOrEmpty(state.processIdServiceId))
                {
                    Char delimiter = '.';
                    string[] arrayInformation = state.processIdServiceId.Split(delimiter);
                    int processId = Convert.ToInt32(arrayInformation[0]);
                    int serviceId = Convert.ToInt32(arrayInformation[1]);
                    string currentAppoinmentDate = arrayInformation[2];
                    DateTime dateFromString = DateTime.Parse(currentAppoinmentDate, System.Globalization.CultureInfo.CurrentCulture);
                    try
                    {
                        listCalendars = new List <OTempus.Library.Class.Calendar>();

                        listCalendars = GetCalendar(serviceId.ToString(), dateFromString);

                        if (listCalendars.Count == 0)
                        {
                            throw new Exception("No records found");
                        }
                        else
                        {
                            foreach (var calendar in listCalendars)
                            {
                                string data = calendar.Id + "." + calendar.CalendarDate.ToString();
                                string data1 = Utilities.Util.GetDateWithOutTime(calendar.CalendarDate.ToString());//we see this in form flow
                                field
                                .AddDescription(data, data1)
                                .AddTerms(data, data1);
                            }
                            return await Task.FromResult(true);
                        } //End else
                    }     //End try
                    catch (Exception e) { }
                }
                return await Task.FromResult(true);
            }))
                   #endregion
                   #region Period day
                   .Field(nameof(ReservationReschedule.dayPeriod))
                   #endregion
                   #region hour
                   .Field(new FieldReflector <ReservationReschedule>(nameof(ReservationReschedule.Hour))
                          .SetType(null)
                          .SetDefine(async(state, value) =>
            {
                string date;
                List <OTempus.Library.Class.Calendar> listCalendars;
                List <CalendarSlot> listGetAvailablesSlots;
                if (!String.IsNullOrEmpty(state.Date) && !String.IsNullOrEmpty(state.dayPeriod.ToString()) && !String.IsNullOrEmpty(state.processIdServiceId))
                {
                    Char delimiter = '.';
                    string[] arrayInformation = state.processIdServiceId.Split(delimiter);
                    int processId = Convert.ToInt32(arrayInformation[0]);
                    int serviceId = Convert.ToInt32(arrayInformation[1]);
                    string currentAppoinmentDate = arrayInformation[2];
                    DateTime dateFromString = DateTime.Parse(currentAppoinmentDate, System.Globalization.CultureInfo.CurrentCulture);


                    int periodDay = Convert.ToInt32(Utilities.Util.GetIntPeriodDay(state.dayPeriod.ToString()));
                    string calendarId = Utilities.Util.GetCalendarIdFromBotOption(state.Date);
                    try
                    {
                        listCalendars = new List <OTempus.Library.Class.Calendar>();
                        date = state.Date;
                        listCalendars = GetCalendar(serviceId.ToString(), dateFromString);
                        listGetAvailablesSlots = new List <CalendarSlot>();

                        StringBuilder response = new StringBuilder();
                        response.Append("Not exists slots").ToString();
                    }
                    catch (Exception ex)
                    {
                        throw new Exception("Here are the error: " + ex.Message);
                    }
                    date = state.Date.ToString();
                    if (listCalendars.Count > 0)
                    {
                        listGetAvailablesSlots = AppoinmentService.GetSlotsByPeriod(Convert.ToInt32(calendarId), periodDay.ToString(), 0.ToString());
                        if (listGetAvailablesSlots.Count > 0)
                        {
                            int cont = 0;
                            foreach (OTempus.Library.Class.CalendarSlot calendarSlots in listGetAvailablesSlots)
                            {
                                if (calendarSlots.Status.ToString() == "Vacant")
                                {
                                    string data = calendarSlots.StartTime.ToString();
                                    DateTime date1 = DateTime.Today;
                                    date1 = date1.AddMinutes(calendarSlots.StartTime);
                                    string data1 = date1.ToShortTimeString();
                                    //string data1 = string.Format("{0:hh:mm-tt}", date1);
                                    //assign the calendar id
                                    value
                                    .AddDescription(data1, data1)
                                    .AddTerms(data1, data1);
                                    cont++;
                                }
                            }
                            return await Task.FromResult(true);
                        }
                        else
                        {
                            throw new Exception("No records found");
                        }
                    }
                    else
                    {
                        throw new Exception("No records found");
                    }
                }
                return await Task.FromResult(false);
            }))
                   .Field(new FieldReflector <ReservationReschedule>(nameof(ReservationReschedule._customerId)).SetActive(InactiveField))

                   #endregion
                   .OnCompletion(processOrder)
                   .Build());
        }
Esempio n. 5
0
        public static IForm <ReservationStatus> BuildForm()
        {
            //Instance of library for manage appoinments
            WebAppoinmentsClientLibrary.Appoinments       appointmentLibrary = new WebAppoinmentsClientLibrary.Appoinments();
            OnCompletionAsyncDelegate <ReservationStatus> processOrder       = async(context, state) =>
            {
                //Get the appoinment by appoinment id
                AppointmentGetResults _appointment = AppoinmentService.GetAppointmentById(Convert.ToInt32(state.appointmentId));

                if (_appointment != null)
                {
                    await context.PostAsync($"Appointment Details:" +
                                            " \n* Ticket: " + _appointment.QCode + _appointment.QNumber +
                                            " \n* Service name: " + _appointment.ServiceName +
                                            " \n* Appointment date: " + _appointment.AppointmentDate

                                            );
                }
                // in other hand we can't find the record, so we will send the appropiate message
                else
                {
                    await context.PostAsync($"I don't found record with the appointment id: \n* " + state.appointmentId);
                }
            };
            CultureInfo ci = new CultureInfo("en");

            Thread.CurrentThread.CurrentCulture   = ci;
            Thread.CurrentThread.CurrentUICulture = ci;
            var culture  = Thread.CurrentThread.CurrentUICulture;
            var form     = new FormBuilder <ReservationStatus>();
            var yesTerms = form.Configuration.Yes.ToList();
            var noTerms  = form.Configuration.No.ToList();

            yesTerms.Add("Yes");
            noTerms.Add("No");
            form.Configuration.Yes = yesTerms.ToArray();
            return(form
                   .Field(new FieldReflector <ReservationStatus>(nameof(ReservationStatus.appointmentId))
                          .SetType(null)
                          .SetDefine(async(state, field) =>
            {
                //Get the actual user state of the customer
                ACFCustomer customerState = new ACFCustomer();

                int customerIdState = 0;
                //customerIdState = customerState.CustomerId;
                customerIdState = state._customerId;

                string personalIdState = string.Empty;
                //Instance of library for manage customers
                WebAppoinmentsClientLibrary.Customers customerLibrary = new WebAppoinmentsClientLibrary.Customers();

                //Instance of library for manage cases
                WebAppoinmentsClientLibrary.Cases caseLibrary = new WebAppoinmentsClientLibrary.Cases();
                //Here we will to find the customer by customer id or personal id
                Customer customer = null;
                if (!string.IsNullOrEmpty(customerIdState.ToString()))
                {
                    //Get the object ObjectCustomer and inside of this the object Customer
                    try
                    {
                        customer = customerLibrary.GetCustomer(customerIdState).Customer;
                    }
                    catch (Exception)
                    {
                        // throw; here we not send the exception beacuse we need to do the next method below
                    }
                }
                //If not found by customer id , we will try to find by personal id
                else
                {
                    int idType = 0;
                    //Get the object ObjectCustomer and inside of this the object Customer
                    try
                    {
                        customer = customerLibrary.GetCustomerByPersonalId(personalIdState, idType).Customer;
                    }
                    catch (Exception)
                    {
                        //throw;
                    }
                }

                if (customer == null)
                {
                    throw new Exception("No records found");
                }
                else
                {
                    //Declaration of Calendar Get Slots Results object
                    CalendarGetSlotsResults slotToShowInformation = new CalendarGetSlotsResults();
                    //Set the parameters for get the expected appoinments
                    int customerTypeId = 0;
                    string customerTypeName = "";
                    int customerId = customer.Id;
                    DateTime startDate = DateTime.Today;
                    //here we add ten days to the startdate
                    DateTime endDate = startDate.AddDays(10);
                    string fromDate = startDate.ToString();
                    string toDate = endDate.ToString();
                    string typeSeriaizer = "XML";

                    //Declaration of the ocject to save the result of the GetExpectedAppoinment
                    ObjectCustomerGetExpectedAppointmentsResults objectCustomerGetExpectedAppointmentsResults = new ObjectCustomerGetExpectedAppointmentsResults();
                    objectCustomerGetExpectedAppointmentsResults = customerLibrary.GetExpectedAppoinment(customerTypeId, customerTypeName, customerId, startDate, endDate, typeSeriaizer);
                    if (objectCustomerGetExpectedAppointmentsResults.ListCustomerGetExpectedAppointmentsResults.Count > 0)
                    {
                        foreach (CustomerGetExpectedAppointmentsResults listCustomer in objectCustomerGetExpectedAppointmentsResults.ListCustomerGetExpectedAppointmentsResults)
                        {
                            //At first I need to find the appoinment by appoiment id, for saw the actual status
                            Appointment appointment = appointmentLibrary.GetAppoinment(listCustomer.AppointmentId).AppointmentInformation;
                            //string data = appointment.AppointmentDate.ToString();
                            string data = string.Format("{0:dd/MM/yyyy-hh:mmtt}", appointment.AppointmentDate);

                            field
                            .AddDescription(listCustomer.AppointmentId.ToString(), data + "|" + listCustomer.ServiceName)                  //here we put the process id and the date of the appointment of this process
                            .AddTerms(listCustomer.AppointmentId.ToString(), data + "|" + listCustomer.ServiceName);
                        }
                        return await Task.FromResult(true);
                    }
                    else
                    {
                        await ReservationCancel.context.PostAsync($"No records found");
                        throw new Exception("No records found");
                    }
                }
            }))
                   .Field(new FieldReflector <ReservationStatus>(nameof(ReservationStatus._customerId)).SetActive(InactiveField))
                   .AddRemainingFields()
                   .OnCompletion(processOrder)
                   .Build());
        }
Esempio n. 6
0
        public static IForm <StatusFormApp> BuildForm()
        {
            OnCompletionAsyncDelegate <StatusFormApp> processOrder = async(context, state) =>
            {
                //Get the actual user state of the customer
                ACFCustomer customerState = new ACFCustomer();
                try
                {
                    if (!context.UserData.TryGetValue <ACFCustomer>("customerState", out customerState))
                    {
                        customerState = new ACFCustomer();
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception("Not exists a user session");
                }
                //Instance of library for manage customers
                WebAppoinmentsClientLibrary.Customers customerLibrary = new WebAppoinmentsClientLibrary.Customers();
                //Instance of library for manage appoinments
                WebAppoinmentsClientLibrary.Appoinments appointmentLibrary = new WebAppoinmentsClientLibrary.Appoinments();
                //Instance of library for manage cases
                WebAppoinmentsClientLibrary.Cases caseLibrary = new WebAppoinmentsClientLibrary.Cases();
                //Here we will to find the customer by customer id or personal id
                Customer customer = null;
                if (!String.IsNullOrEmpty(customerState.CustomerId.ToString()))
                {
                    //Get the object ObjectCustomer and inside of this the object Customer
                    try
                    {
                        customer = customerLibrary.GetCustomer(customerState.CustomerId).Customer;
                    }
                    catch (Exception)
                    {
                        // throw; here we not send the exception beacuse we need to do the next method below
                    }
                }
                //If not found by customer id , we will try to find by personal id
                if (customer.Id <= 0)
                {
                    int idType = 0;
                    //GEt the object ObjectCustomer and inside of this the object Customer
                    try
                    {
                        customer = customerLibrary.GetCustomerByPersonalId(customerState.PersonaId, idType).Customer;
                    }
                    catch (Exception)
                    {
                        //throw;
                    }
                }

                if (customer == null)
                {
                    await context.PostAsync($"The user is not valid");
                }
                else
                {
                    int customerId = customer.Id;

                    //get the appoinment id for filter in the below results
                    int appoinmentId = state.appoinmentId;


                    //Get a list of cases by customer id (no trae resultados)
                    List <Case>        listCases = caseLibrary.GetCase(customerId).CaseList;
                    CaseCustomerResult cd        = new CaseCustomerResult();

                    //Get the appoinment by appoinment id
                    AppointmentGetResults _appoinment = AppoinmentService.GetAppointmentById(appoinmentId);

                    //Declare a case for save the specific case that we search
                    Case caseForSaveResult = new Case();

                    string test = caseForSaveResult.OTUnitName;

                    if (_appoinment.ProcessId > 0)
                    {
                        await context.PostAsync($"The appointment have the next information " +
                                                " \n* Process Id: " + _appoinment.ProcessId +
                                                " \n* Appointment date: " + _appoinment.AppointmentDate +
                                                " \n* Q-Code: " + _appoinment.QCode +
                                                " \n* Q-Number: " + _appoinment.QNumber +
                                                //" \n* Arrival date: " + _appoinment.ArrivalDate +
                                                " \n* Customer Id: " + _appoinment.CustomerId +
                                                // " \n* Date called: " + _appoinment.DateCalled +
                                                // " \n* Name: " + _appoinment.Name +
                                                " \n* Case Id: " + _appoinment.CaseId +
                                                //  " \n* Is Walkin: " + _appoinment.IsWalkIn +
                                                " \n* Is Active: " + _appoinment.IsActive +
                                                " \n* Service Name: " + _appoinment.ServiceName
                                                // " \n* Cancelreason name: " + _appoinment.CancelationReasonName
                                                );
                    }
                    // in other hand we can't find the record, so we will send the appropiate message
                    else
                    {
                        await context.PostAsync($"I don't found record with the appointment id: \n*" + state.appoinmentId);
                    }
                }
            };
            CultureInfo ci = new CultureInfo("en");

            Thread.CurrentThread.CurrentCulture   = ci;
            Thread.CurrentThread.CurrentUICulture = ci;
            var culture  = Thread.CurrentThread.CurrentUICulture;
            var form     = new FormBuilder <StatusFormApp>();
            var yesTerms = form.Configuration.Yes.ToList();
            var noTerms  = form.Configuration.No.ToList();

            yesTerms.Add("Yes");
            noTerms.Add("No");
            form.Configuration.Yes = yesTerms.ToArray();
            return(form.Message("Fill the information for search the appointment, please")
                   .Field(nameof(appoinmentId))
                   .Confirm("Are you selected the appointment id: {appoinmentId}: ? (yes/no)")
                   .AddRemainingFields()
                   .OnCompletion(processOrder)
                   .Build());
        }
Esempio n. 7
0
        /// <summary>
        /// Create a IForm(Form flow) based in BookFormApp object
        /// </summary>
        /// <returns></returns>
        ///
        public static IForm <BookFormApp> BuildForm()
        {
            #region processOrder
            OnCompletionAsyncDelegate <BookFormApp> processOrder = async(context, state) =>
            {
                //Get the actual user state of the customer
                ACFCustomer customerState = new ACFCustomer();
                try
                {
                    if (!context.UserData.TryGetValue <ACFCustomer>("customerState", out customerState))
                    {
                        customerState = new ACFCustomer();
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception("Not exists a user session");
                }
                try
                {
                    ResultObjectBase resultObjectBase = new ResultObjectBase();
                    int serviceID = 0;
                    int unitId    = 0;
                    unitId = Utilities.Util.GetUnitIdFromBotOption(state.Office);
                    string ordinalNumber = state.Hour.ToString();

                    try
                    {
                        List <Service> listService = AppoinmentService.listServicesByName(state.Service, 1, "en", false, unitId);
                        serviceID = listService[0].Id;
                    }
                    catch (Exception)
                    {
                        throw new Exception("I don't found appointments with the service: " + state.Service);
                    }

                    try
                    {
                        resultObjectBase = AppoinmentService.SetAppoinment(0, serviceID, customerState.CustomerId, Convert.ToInt32(ordinalNumber), Convert.ToInt32(
                                                                               state.CalendarId));
                        //Get the appoinment by appoinment id
                        AppointmentGetResults _appointment = AppoinmentService.GetAppointmentById(resultObjectBase.Id);
                        await context.PostAsync("Your appointment has been scheduled, Ticket: " + _appointment.QCode + _appointment.QNumber);
                    }
                    catch (Exception ex)
                    {
                        throw new Exception("I can't book the appointment, error: " + ex.Message);
                    }
                }
                catch (Exception ex)
                {
                    await context.PostAsync($"Failed with message: {ex.Message}");
                }
            };
            #endregion
            #region Define language and FormBuilder
            CultureInfo ci = new CultureInfo("en");
            Thread.CurrentThread.CurrentCulture   = ci;
            Thread.CurrentThread.CurrentUICulture = ci;
            FormBuilder <BookFormApp> form = new FormBuilder <BookFormApp>();
            return(form
                   #endregion
                   #region office
                   .Field(new FieldReflector <BookFormApp>(nameof(Office))
                          .SetType(null)
                          .SetDefine(async(state, field) =>
            {
                List <Unit> list = GetListUnitsConfigured();
                string data = string.Empty;
                if (list.Count > 0)
                {
                    foreach (var unit in list)
                    {
                        //This format is important, follow this structure
                        data = unit.Id + "." + unit.Name;
                        field
                        .AddDescription(data, unit.Name)
                        .AddTerms(data, unit.Name);
                    }

                    return await Task.FromResult(true);
                }
                else
                {
                    await context.PostAsync($"No records found");
                    throw new Exception("No records found");
                }
            }))
                   #endregion
                   #region service
                   .Field(new FieldReflector <BookFormApp>(nameof(Service))
                          .SetType(null)
                          .SetDefine((state, field) =>
            {
                int unitId = 0;
                if (!String.IsNullOrEmpty(state.Office))
                {
                    //Get the unit id by the option above selected
                    unitId = Utilities.Util.GetUnitIdFromBotOption(state.Office);
                    if (GetServicesOtempues(unitId).Count > 0)
                    {
                        foreach (var prod in GetServicesOtempues(unitId))
                        {
                            field
                            .AddDescription(prod.Name, prod.Name)
                            .AddTerms(prod.Name, prod.Name);
                        }

                        return Task.FromResult(true);
                    }
                    else
                    {
                        throw new Exception("Not exists services");
                    }
                }
                return Task.FromResult(true);
            }))
                   #endregion
                   #region Date
                   .Field(new FieldReflector <BookFormApp>(nameof(Date))
                          .SetType(null)
                          .SetDefine(async(state, field) =>
            {
                List <Service> listService;
                int unitId = 0;
                List <OTempus.Library.Class.Calendar> listCalendars;
                StringBuilder response = new StringBuilder();
                List <CalendarGetSlotsResults> listGetAvailablesSlots = new List <CalendarGetSlotsResults>();
                if (!String.IsNullOrEmpty(state.Service) && !String.IsNullOrEmpty(state.Office))
                {
                    unitId = Utilities.Util.GetUnitIdFromBotOption(state.Office);
                    try
                    {
                        listService = AppoinmentService.listServicesByName(state.Service, 1, "en", false, unitId);
                        int serviceID = listService[0].Id;
                        listCalendars = new List <OTempus.Library.Class.Calendar>();
                        if (GetServicesOtempues(unitId).Count > 0)
                        {
                            listCalendars = GetCalendar(serviceID.ToString(), DateTime.Today);

                            if (listCalendars.Count == 0)
                            {
                                await context.PostAsync($"No records found");

                                throw new Exception("No records found");
                            }
                            else
                            {
                                foreach (var calendar in listCalendars)
                                {
                                    string data = calendar.Id + ".-" + calendar.CalendarDate.ToString();
                                    string data1 = Utilities.Util.GetDateWithOutTime(calendar.CalendarDate);//we see this in form flow
                                    field
                                    .AddDescription(data, data1)
                                    .AddTerms(data, data1);
                                }

                                return await Task.FromResult(true);
                            } //End else
                        }     //End if
                        else
                        {
                            await context.PostAsync($"No records found");

                            throw new Exception("No records found");
                        }
                    }//End try
                    catch (Exception e) { throw e; }
                }
                return await Task.FromResult(true);
            }))
                   #endregion
                   #region calendarId
                   .Field(new FieldReflector <BookFormApp>(nameof(CalendarId)).SetActive(InactiveField))
                   #endregion
                   #region ordinal Slot
                   .Field(new FieldReflector <BookFormApp>(nameof(OrdinalSlot)).SetActive(InactiveField))
                   #endregion
                   #region Period day
                   .Field(nameof(dayPeriod))
                   #endregion
                   #region hour
                   .Field(new FieldReflector <BookFormApp>(nameof(Hour))
                          .SetType(null)
                          .SetDefine(async(state, value) =>
            {
                string date;
                string service;
                List <Service> listService;
                List <OTempus.Library.Class.Calendar> listCalendars;
                listCalendars = new List <OTempus.Library.Class.Calendar>();
                List <CalendarSlot> listGetAvailablesSlots;
                if (!String.IsNullOrEmpty(state.Date) && !String.IsNullOrEmpty(state.Service) && !String.IsNullOrEmpty(state.Office) && !String.IsNullOrEmpty(state.dayPeriod.ToString()))
                {
                    int periodDay = Convert.ToInt32(Utilities.Util.GetIntPeriodDay(state.dayPeriod.ToString()));
                    int unitId = Utilities.Util.GetUnitIdFromBotOption(state.Office);
                    string calendarId = Utilities.Util.GetCalendarIdFromBotOption(state.Date);
                    //assign the calendar id
                    state.CalendarId = calendarId;
                    try
                    {
                        listService = AppoinmentService.listServicesByName(state.Service, 1, "en", false, unitId);
                        if (listService.Count > 0)
                        {
                            //It find the time one record, but in the case this found two,
                            int serviceID = listService[0].Id;

                            date = state.Date; service = state.Service;
                            if (GetServicesOtempues(unitId).Count > 0)
                            {
                                //Service two and date...
                                listCalendars = GetCalendar(serviceID.ToString(), DateTime.Today);
                            }
                            else
                            {
                                await context.PostAsync($"No records found");
                                throw new Exception("No records found");
                            }
                            listGetAvailablesSlots = new List <CalendarSlot>();

                            StringBuilder response = new StringBuilder();
                            response.Append("Not exists slots").ToString();
                        }
                        else
                        {
                            await context.PostAsync($"No records found");
                            throw new Exception("No records found");
                        }
                    }
                    catch (Exception ex)
                    {
                        throw new Exception("Here are the error: " + ex.Message);
                    }
                    date = state.Date.ToString();
                    service = state.Service.ToString();
                    if (listCalendars.Count > 0)
                    {
                        listGetAvailablesSlots = AppoinmentService.GetSlotsByPeriod(Convert.ToInt32(calendarId), periodDay.ToString(), 0.ToString());
                        int cont = 0;
                        if (listGetAvailablesSlots.Count > 0)
                        {
                            foreach (OTempus.Library.Class.CalendarSlot calendarSlots in listGetAvailablesSlots)
                            {
                                //string hour = Utilities.Util.GetHourFromStartDate(calendarSlots.DisplayStartTime.ToString()); ;
                                if (calendarSlots.Status.ToString() == "Vacant")
                                {
                                    string data = calendarSlots.OrdinalNumber.ToString();
                                    DateTime date1 = DateTime.Today;
                                    date1 = date1.AddMinutes(calendarSlots.StartTime);
                                    string data1 = string.Format("{0:hh:mm-tt}", date1);
                                    value
                                    .AddDescription(data, data1)
                                    .AddTerms(data, data1);
                                    cont++;
                                }
                            }
                            return await Task.FromResult(true);
                        }
                        else
                        {
                            await context.PostAsync($"No records found");
                            throw new Exception("No records found");
                        }
                    }
                    else
                    {
                        throw new Exception("No records found");
                    }
                }
                return await Task.FromResult(false);
            }))
                   #endregion
                   #region Confirm commented

                   /* .Confirm("Are you selected the information: " +
                    * "\n* Office: {Office} " +
                    * "\n* Slot:  {Hour} " +
                    * "\n* Service:  {Service}? \n" +
                    * "(yes/no)") This lines are commented because, when the user select no,  the user can create inconsistence when user book the appointment (I try to solve by the best way)*/
                   #endregion
                   .AddRemainingFields()
                   .OnCompletion(processOrder)
                   .Build());
        }