protected override ValidationResult IsValid(object value, ValidationContext validationContext) { CrearVehiculoModel vehiculo = (CrearVehiculoModel)validationContext.ObjectInstance; if (!string.IsNullOrEmpty(vehiculo.propietario)) { using (Iceberg_Context context = new Iceberg_Context()) { if (value != null || string.IsNullOrEmpty(value.ToString())) { int nit = Convert.ToInt32(value); icb_terceros buscarNit = context.icb_terceros.FirstOrDefault(x => x.tercero_id == nit); if (buscarNit == null) { return(new ValidationResult("El documento no se encontro")); } } } } return(ValidationResult.Success); }
protected override ValidationResult IsValid(object value, ValidationContext validationContext) { CrearVehiculoModel vehiculo = (CrearVehiculoModel)validationContext.ObjectInstance; if (!string.IsNullOrEmpty(vehiculo.nitaseguradora)) { using (Iceberg_Context context = new Iceberg_Context()) { if (value != null || string.IsNullOrEmpty(value.ToString())) { string nit = value.ToString(); icb_terceros buscarNit = context.icb_terceros.FirstOrDefault(x => x.doc_tercero == nit); if (buscarNit == null) { return(new ValidationResult("El nit no se encontro")); } } } } return(ValidationResult.Success); }