public UpdateTreatmentSessionValidator( TreatmentSessionValidator treatmentSessionValidator, AbstractValidator <IReference> referenceValidator) { RuleFor(m => m) .SetValidator(referenceValidator) .SetValidator(treatmentSessionValidator); }
public TreatmentSessionBusinessValidator( IStringLocalizer <TreatmentSessionBusinessValidator> localizer, TreatmentSessionValidator simpleValidator, IReadRepository <TreatmentSession> treatmentSessionRepository) { RuleFor(m => m) .SetValidator(simpleValidator) .DependentRules(() => { RuleFor(m => m.PatientReferenceId) .MustAsync((m, ctx, ct) => HasNoOverlappingsForPatient(m, ct)) .WithMessage(localizer[OverlappingTreatmentSessionForPatientMessageName]); RuleFor(m => m.DentalTeamReferenceId) .MustAsync((m, ctx, ct) => HasNoOverlappingsForDentalTeam(m, ct)) .WithMessage(localizer[OverlappingTreatmentSessionForDentalTeamMessageName]); }); TreatmentSessionRepository = treatmentSessionRepository; }