Beispiel #1
0
            protected override ValidationResult IsValid(object value, ValidationContext validationContext)
            {
                Cotizacion cotizacion = (Cotizacion)validationContext.ObjectInstance;

                using (Iceberg_Context context = new Iceberg_Context())
                {
                    tp_origen buscarSiEsVitrina = context.tp_origen.FirstOrDefault(x => x.tporigen_id == cotizacion.tporigen_id);
                    if (buscarSiEsVitrina != null)
                    {
                        if (buscarSiEsVitrina.subfuente == true)
                        {
                            if (value == null || string.IsNullOrEmpty(value.ToString()))
                            {
                                return(new ValidationResult("El campo " + validationContext.DisplayName + " es requerido"));
                            }
                        }
                    }
                }

                return(ValidationResult.Success);
            }
Beispiel #2
0
            protected override ValidationResult IsValid(object value, ValidationContext validationContext)
            {
                Prospecto prospecto = (Prospecto)validationContext.ObjectInstance;

                using (Iceberg_Context context = new Iceberg_Context())
                {
                    tp_origen buscarSiRequiere =
                        context.tp_origen.FirstOrDefault(x => x.tporigen_id == prospecto.tporigen_id);
                    if (buscarSiRequiere != null)
                    {
                        if (buscarSiRequiere.evento)
                        {
                            if (value == null || string.IsNullOrEmpty(value.ToString()) || value.ToString() == "0")
                            {
                                return(new ValidationResult("El campo " + validationContext.DisplayName +
                                                            " es requerido"));
                            }
                        }
                    }
                }

                return(ValidationResult.Success);
            }