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

                using (Iceberg_Context context = new Iceberg_Context())
                {
                    tp_documento buscarSiEsNit = context.tp_documento.FirstOrDefault(x => x.tpdoc_id == cotizacion.tpdoc_id);
                    if (buscarSiEsNit != null)
                    {
                        if (!buscarSiEsNit.tpdoc_nombre.ToUpper().Contains("NIT"))
                        {
                            if (value == null || string.IsNullOrEmpty(value.ToString()))
                            {
                                return(new ValidationResult("El campo " + validationContext.DisplayName + " es requerido"));
                            }
                        }
                    }
                    else if (cotizacion.tpdoc_id == 0)
                    {
                        return(new ValidationResult("El campo " + validationContext.DisplayName + " es requerido"));
                    }
                }

                return(ValidationResult.Success);
            }
예제 #2
0
            protected override ValidationResult IsValid(object value, ValidationContext validationContext)
            {
                Cotizacion cotizacion = (Cotizacion)validationContext.ObjectInstance;

                if (cotizacion.tporigen_id == 2)
                {
                    if (value == null || string.IsNullOrEmpty(value.ToString()))
                    {
                        return(new ValidationResult("El campo " + validationContext.DisplayName + " es requerido"));
                    }
                }

                return(ValidationResult.Success);
            }
예제 #3
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);
            }