public void MustBeFromSameOrganisation()
 {
     RuleFor(x => x)
     .Must(x =>
     {
         var evidence = _evidenceDatastore.ById(x.EvidenceId);
         var claim    = _claimDatastore.ById(evidence.ClaimId);
         var soln     = _solutionDatastore.ById(claim.SolutionId);
         var orgId    = _context.OrganisationId();
         return(soln.OrganisationId == orgId);
     })
     .WithMessage("Must be from same organisation");
 }
Example #2
0
 public void PreviousMustBeForSameClaim()
 {
     RuleFor(x => x)
     .Must(x =>
     {
         var evidence = _evidenceDatastore.ById(x.PreviousId);
         return(x.ClaimId == evidence.ClaimId);
     })
     .When(x => !string.IsNullOrEmpty(x.PreviousId))
     .WithMessage("Previous evidence must be for same claim");
 }
        public T FilterForSupplier(T input)
        {
            // Supplier: only own Reviews
            foreach (var review in input)
            {
                var evidence = _evidenceDatastore.ById(review.EvidenceId);
                var claim    = _claimDatastore.ById(evidence.ClaimId);
                var soln     = _solutionDatastore.ById(claim.SolutionId);
                if (_context.OrganisationId() != soln?.OrganisationId)
                {
                    return(default(T));
                }
            }

            return(input);
        }