public static ValidationResult Validate(LandListing landListing, string ruleSet = ResidentialListingValidator.NormalRuleSet) { var validator = new LandListingValidator(); return(string.IsNullOrWhiteSpace(ruleSet) ? validator.Validate(landListing) : validator.Validate(landListing, ruleSet: ruleSet)); }
public static ValidationResult Validate(Listing listing, string ruleSet = null) { if (listing is ResidentialListing) { var validator = new ResidentialListingValidator(); return(string.IsNullOrWhiteSpace(ruleSet) ? validator.Validate(listing as ResidentialListing) : validator.Validate(listing as ResidentialListing, ruleSet: RentalListingValidator.MinimumRuleSet)); } if (listing is RentalListing) { var validator = new RentalListingValidator(); return(string.IsNullOrWhiteSpace(ruleSet) ? validator.Validate(listing as RentalListing) : validator.Validate(listing as RentalListing, ruleSet: RentalListingValidator.MinimumRuleSet)); } if (listing is RuralListing) { var validator = new RuralListingValidator(); return(string.IsNullOrWhiteSpace(ruleSet) ? validator.Validate(listing as RuralListing) : validator.Validate(listing as RuralListing, ruleSet: RentalListingValidator.MinimumRuleSet));; } if (listing is LandListing) { var validator = new LandListingValidator(); return(string.IsNullOrWhiteSpace(ruleSet) ? validator.Validate(listing as LandListing) : validator.Validate(listing as LandListing, ruleSet: RentalListingValidator.MinimumRuleSet)); } var errorMessage = string.Format( "Tried to validate an unhandled Listing type: {0}. Only Residental, Rental, Rural and Land listing types are supported.", listing.GetType()); throw new Exception(errorMessage); }
public static ValidationResult Validate(Listing listing, bool isTheMinimumDataToStoreAListing = true) { if (listing is ResidentialListing) { var validator = new ResidentialListingValidator(); return(isTheMinimumDataToStoreAListing ? validator.Validate(listing as ResidentialListing, ruleSet: ResidentialListingValidator.MinimumRuleSet) : validator.Validate(listing as ResidentialListing)); } if (listing is RentalListing) { var validator = new RentalListingValidator(); return(isTheMinimumDataToStoreAListing ? validator.Validate(listing as RentalListing, ruleSet: RentalListingValidator.MinimumRuleSet) : validator.Validate(listing as RentalListing)); } if (listing is RuralListing) { var validator = new RuralListingValidator(); return(isTheMinimumDataToStoreAListing ? validator.Validate(listing as RuralListing, ruleSet: RuralListingValidator.MinimumRuleSet) : validator.Validate(listing as RuralListing));; } if (listing is LandListing) { var validator = new LandListingValidator(); return(isTheMinimumDataToStoreAListing ? validator.Validate(listing as LandListing, ruleSet: LandListingValidator.MinimumRuleSet) : validator.Validate(listing as LandListing)); } var errorMessage = string.Format( "Tried to validate an unhandled Listing type: {0}. Only Residental, Rental, Rural and Land listing types are supported.", listing.GetType()); throw new Exception(errorMessage); }
public static ValidationResult Validate(Listing listing, bool isTheMinimumDataToStoreAListing = true) { if (listing is ResidentialListing) { var validator = new ResidentialListingValidator(); return isTheMinimumDataToStoreAListing ? validator.Validate(listing as ResidentialListing, ruleSet: ResidentialListingValidator.MinimumRuleSet) : validator.Validate(listing as ResidentialListing); } if (listing is RentalListing) { var validator = new RentalListingValidator(); return isTheMinimumDataToStoreAListing ? validator.Validate(listing as RentalListing, ruleSet: RentalListingValidator.MinimumRuleSet) : validator.Validate(listing as RentalListing); } if (listing is RuralListing) { var validator = new RuralListingValidator(); return isTheMinimumDataToStoreAListing ? validator.Validate(listing as RuralListing, ruleSet: RuralListingValidator.MinimumRuleSet) : validator.Validate(listing as RuralListing);; } if (listing is LandListing) { var validator = new LandListingValidator(); return isTheMinimumDataToStoreAListing ? validator.Validate(listing as LandListing, ruleSet: LandListingValidator.MinimumRuleSet) : validator.Validate(listing as LandListing); } var errorMessage = string.Format( "Tried to validate an unhandled Listing type: {0}. Only Residental, Rental, Rural and Land listing types are supported.", listing.GetType()); throw new Exception(errorMessage); }