コード例 #1
0
        private static Task <ValidateResult> ValidateNumPeople(BookingFormShort1 state, object response)
        {
            var    result    = new ValidateResult();
            string numPeople = response.ToString();
            int    people    = state.No_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));
        }
コード例 #2
0
        private static Task <ValidateResult> ValidateKids(BookingFormShort1 state, object response)
        {
            var result = new ValidateResult();
            int kids   = Convert.ToInt32(response);
            int people = state.No_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));
        }
コード例 #3
0
        private static Task <ValidateResult> ValidateTime(BookingFormShort1 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));
        }
コード例 #4
0
        /*private static bool BookingEnabled(BookingForm state) =>
         *  !string.IsNullOrWhiteSpace(state.Email) && !string.IsNullOrWhiteSpace(state.Name);
         */

        private static Task <ValidateResult> ValidateDate(BookingFormShort1 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));
        }