Exemplo n.º 1
0
        private static Task <ValidateResult> ValidateNumPeople(BookingForm1 state, object response)
        {
            var    result    = new ValidateResult();
            string numPeople = response.ToString();
            int    people    = state.Num_Huespedes;

            if (!Regex.IsMatch(numPeople, @"^[0-9]+$"))
            {
                result.IsValid  = false;
                result.Feedback = "Número de personas no válido. Por favor, introduce únicamente valores numéricos.";
            }
            else
            {
                result.IsValid = true;
                result.Value   = response;
            }
            return(Task.FromResult(result));
        }
Exemplo n.º 2
0
        private static Task <ValidateResult> ValidateKids(BookingForm1 state, object response)
        {
            var result = new ValidateResult();
            int kids   = Convert.ToInt32(response);
            int people = state.Num_Huespedes;

            if (people < kids)
            {
                // If time not available
                result.IsValid  = false;
                result.Feedback = "Número de niños no válido. Introduce un número igual o menor al número de huéspedes.";
            }
            else
            {
                result.IsValid = true;
                result.Value   = response;
            }
            return(Task.FromResult(result));
        }
Exemplo n.º 3
0
        private static Task <ValidateResult> ValidateTime(BookingForm1 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 = "Lo sentimos, ¡ese momento no está disponible! Los horarios que están disponibles son: 18:30, 19:00, 20:00, 21:00";
            }
            else
            {
                result.IsValid = true;
                result.Value   = response;
            }
            return(Task.FromResult(result));
        }
Exemplo n.º 4
0
        ///

        /*private static bool BookingEnabled(BookingForm state) =>
         *  !string.IsNullOrWhiteSpace(state.Email) && !string.IsNullOrWhiteSpace(state.Name);
         */

        // Cache of culture specific forms.
        //       private static ConcurrentDictionary<CultureInfo, IForm<BookingForm1>> _forms = new ConcurrentDictionary<CultureInfo, IForm<BookingForm1>>();



        private static Task <ValidateResult> ValidateDate(BookingForm1 state, object response)
        {
            var      result = new ValidateResult();
            var      dt     = (DateTime)response;
            DateTime today  = DateTime.Today;

            // Do the checks here whether the time is available.
            if (dt <= today)
            {
                // If time not available
                result.IsValid  = false;
                result.Feedback = "Fecha no válida. Introduce una fecha en el futuro contando des de hoy.";
            }
            else
            {
                result.IsValid = true;
                result.Value   = response;
            }
            return(Task.FromResult(result));
        }