Ejemplo n.º 1
0
        public override bool IsValid(object value)
        {
            var jArray = JArray.Parse(value.ToString());

            int[] daps = jArray.ToObject <List <DapModel> >().Select(i => i.DapValue).ToArray();

            HttpContext.Current.Items["daps"] = daps;

            int varas = (int)HttpContext.Current.Items["varas"];

            if ((daps.Length <= 0 && varas <= 0) || (daps.Length > 0 && varas > 0))
            {
                this.ErrorMessage = "Varas y/o Daps inválidos";
                return(false);
            }

            for (int i = 0; i < daps.Length; i++)
            {
                if (!DecimalIsValid.IsValid(daps[i], ProjectOrganismValidationConstants.DapMinValue, ProjectOrganismValidationConstants.DapMaxValue))
                {
                    this.ErrorMessage = string.Format("DAP numero {0} fuera del rango permitido", i);
                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 2
0
        public override bool IsValid(object value)
        {
            if (value == null)
            {
                return(true);
            }

            this.ErrorMessage = string.Format("La cantidad de caracteres para el comentario exede el máximo de {0}", ConfigurationManager.AppSettings["CommentaryMaxLength"]);
            return(DecimalIsValid.IsValid(((string)value).Length, 0M, ProjectOrganismValidationConstants.CommentaryMaxLength));
        }
Ejemplo n.º 3
0
        public override bool IsValid(object value)
        {
            this.ErrorMessage = string.Format("La cantidad de varas exede el máximo de {0}", ConfigurationManager.AppSettings["VarasMaxCount"]);

            if (value == null || string.IsNullOrEmpty(value.ToString()))
            {
                HttpContext.Current.Items["varas"] = 0;
                return(true);
            }

            bool isValid = DecimalIsValid.IsValid((int)value, 0M, ProjectOrganismValidationConstants.VarasMaxCount);

            if (isValid)
            {
                HttpContext.Current.Items["varas"] = (int)value;
            }

            return(isValid);
        }
Ejemplo n.º 4
0
 public override bool IsValid(object value)
 {
     this.ErrorMessage = "Alto del arbol fuera del rango permitido";
     return(DecimalIsValid.IsValid(value, ProjectOrganismValidationConstants.HeightMinValue, ProjectOrganismValidationConstants.HeightMaxValue));
 }
Ejemplo n.º 5
0
 public override bool IsValid(object value)
 {
     this.ErrorMessage = "Longitud fuera del rango permitido";
     return(DecimalIsValid.IsValid(value, ProjectOrganismValidationConstants.LonMinValue, ProjectOrganismValidationConstants.LonMaxValue));
 }