public void MustBeValidClaim() { RuleFor(x => x) .Must(x => { var claim = _claimsDatastore.ById(x); return(claim != null); }) .WithMessage("Could not find claim"); }
public void SolutionMustBeInReview() { RuleFor(x => x) .Must(x => { var claim = _claimDatastore.ById(x.ClaimId); var soln = _solutionDatastore.ById(claim.SolutionId); return(soln.Status == SolutionReviewStatus); }) .WithMessage("Can only add evidence if solution is in review"); }
public void MustBeSameOrganisation() { RuleFor(x => x) .Must(x => { var orgId = _context.OrganisationId(); var claim = _claimDatastore.ById(x.Id); var claimSoln = _solutionsDatastore.ById(claim?.SolutionId ?? x.SolutionId); return(claimSoln?.OrganisationId == orgId); }) .WithMessage("Cannot create/change claim for other organisation"); }
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"); }
public T FilterForSupplier(T input) { // Supplier: only own Claims foreach (var evidence in input) { var claim = _claimDatastore.ById(evidence.ClaimId); var soln = _solutionDatastore.ById(claim.SolutionId); if (_context.OrganisationId() != soln?.OrganisationId) { return(default(T)); } } return(input); }
public T ById(string id) { return(_filter.Filter(new[] { _datastore.ById(id) }).SingleOrDefault()); }