public static void PlaceBooking(Booking booking) { DataAnnotationsValidationRunner validationRunner = new DataAnnotationsValidationRunner(); IEnumerable <ValidationResult> errors = validationRunner.Validate(booking); if (errors.Any()) { throw new ValidationException(errors.GetErrorMessage()); } }
public static void LogOn(User user) { DataAnnotationsValidationRunner validationRunner = new DataAnnotationsValidationRunner(); IEnumerable <ValidationResult> errors = validationRunner.Validate(user); if (errors.Any()) { throw new ValidationException(errors.GetErrorMessage()); } // perform logon }