public void PreviousMustNotBeInUse() { RuleFor(x => x) .Must(x => { var chains = _evidenceDatastore.ByClaim(x.ClaimId); var allPrevIds = chains.SelectMany(chain => chain.Select(evidence => evidence.PreviousId)); return(!allPrevIds.Contains(x.PreviousId)); }) .When(x => !string.IsNullOrEmpty(x.PreviousId)) .WithMessage("Previous evidence already in use"); }
public IEnumerable <IEnumerable <T> > ByClaim(string claimId) { return(_filter.Filter(_datastore.ByClaim(claimId))); }