public DeleteRequirementDefinitionCommandValidator( IRequirementTypeValidator requirementTypeValidator, IRequirementDefinitionValidator requirementDefinitionValidator, IRowVersionValidator rowVersionValidator) { CascadeMode = CascadeMode.Stop; RuleFor(command => command) .MustAsync(BeAnExistingRequirementDefinitionAsync) .WithMessage(command => "Requirement type and/or requirement definition doesn't exist!") .MustAsync((command, token) => BeAVoidedRequirementDefinitionAsync(command.RequirementDefinitionId, token)) .WithMessage(command => $"Requirement definition is not voided! Requirement definition={command.RequirementDefinitionId}") .MustAsync((command, token) => NotHaveAnyFieldsAsync(command.RequirementDefinitionId, token)) .WithMessage(command => $"Requirement definition has fields! Requirement definition={command.RequirementDefinitionId}") .MustAsync((command, token) => NotHaveAnyTagRequirementsAsync(command.RequirementDefinitionId, token)) .WithMessage(command => $"Tag requirement with this requirement definition exists! Requirement definition={command.RequirementDefinitionId}") .MustAsync((command, token) => NotHaveAnyTagFunctionRequirementsAsync(command.RequirementDefinitionId, token)) .WithMessage(command => $"Tag function requirement with this requirement definition exists! Requirement definition={command.RequirementDefinitionId}") .Must(command => HaveAValidRowVersion(command.RowVersion)) .WithMessage(command => $"Not a valid row version! Row version={command.RowVersion}"); async Task <bool> BeAnExistingRequirementDefinitionAsync(DeleteRequirementDefinitionCommand command, CancellationToken token) => await requirementTypeValidator.RequirementDefinitionExistsAsync(command.RequirementTypeId, command.RequirementDefinitionId, token); async Task <bool> BeAVoidedRequirementDefinitionAsync(int requirementDefinitionId, CancellationToken token) => await requirementDefinitionValidator.IsVoidedAsync(requirementDefinitionId, token); async Task <bool> NotHaveAnyFieldsAsync(int requirementDefinitionId, CancellationToken token) => !await requirementDefinitionValidator.HasAnyFieldsAsync(requirementDefinitionId, token); async Task <bool> NotHaveAnyTagRequirementsAsync(int requirementDefinitionId, CancellationToken token) => !await requirementDefinitionValidator.TagRequirementsExistAsync(requirementDefinitionId, token); async Task <bool> NotHaveAnyTagFunctionRequirementsAsync(int requirementDefinitionId, CancellationToken token) => !await requirementDefinitionValidator.TagFunctionRequirementsExistAsync(requirementDefinitionId, token); bool HaveAValidRowVersion(string rowVersion) => rowVersionValidator.IsValid(rowVersion); }
public UpdateRequirementsCommandValidator(IRequirementDefinitionValidator requirementDefinitionValidator) { CascadeMode = CascadeMode.Stop; When(command => command.Requirements.Any(), () => { RuleFor(command => command.Requirements) .Must(BeUniqueRequirements) .WithMessage("Requirement definitions must be unique!") .MustAsync((_, requirements, token) => RequirementUsageIsForAllJourneysAsync(requirements, token)) .WithMessage(command => "Requirements must include requirements to be used both for supplier and other than suppliers!"); RuleForEach(command => command.Requirements) .MustAsync((_, req, __, token) => BeAnExistingRequirementDefinitionAsync(req, token)) .WithMessage((_, req) => $"Requirement definition doesn't exist! Requirement definition={req.RequirementDefinitionId}") .MustAsync((_, req, __, token) => NotBeAVoidedRequirementDefinitionAsync(req, token)) .WithMessage((_, req) => $"Requirement definition is voided! Requirement definition={req.RequirementDefinitionId}"); }); async Task <bool> BeAnExistingRequirementDefinitionAsync(RequirementForCommand requirement, CancellationToken token) => await requirementDefinitionValidator.ExistsAsync(requirement.RequirementDefinitionId, token); async Task <bool> NotBeAVoidedRequirementDefinitionAsync(RequirementForCommand requirement, CancellationToken token) => !await requirementDefinitionValidator.IsVoidedAsync(requirement.RequirementDefinitionId, token); bool BeUniqueRequirements(IEnumerable <RequirementForCommand> requirements) { var reqIds = requirements.Select(dto => dto.RequirementDefinitionId).ToList(); return(reqIds.Distinct().Count() == reqIds.Count); } async Task <bool> RequirementUsageIsForAllJourneysAsync(IEnumerable <RequirementForCommand> requirements, CancellationToken token) { var reqIds = requirements.Select(dto => dto.RequirementDefinitionId).ToList(); return(await requirementDefinitionValidator.UsageCoversBothForSupplierAndOtherAsync(reqIds, token)); } }
public VoidRequirementDefinitionCommandValidator( IRequirementTypeValidator requirementTypeValidator, IRequirementDefinitionValidator requirementDefinitionValidator, IRowVersionValidator rowVersionValidator ) { CascadeMode = CascadeMode.Stop; RuleFor(command => command) .MustAsync(BeAnExistingRequirementDefinitionAsync) .WithMessage(command => "Requirement type and/or requirement definition doesn't exist!") .MustAsync((command, token) => NotBeAVoidedRequirementDefinitionAsync(command.RequirementDefinitionId, token)) .WithMessage(command => $"Requirement definition is already voided! Requirement definition={command.RequirementDefinitionId}") .Must(command => HaveAValidRowVersion(command.RowVersion)) .WithMessage(command => $"Not a valid row version! Row version={command.RowVersion}"); async Task <bool> BeAnExistingRequirementDefinitionAsync(VoidRequirementDefinitionCommand command, CancellationToken token) => await requirementTypeValidator.RequirementDefinitionExistsAsync(command.RequirementTypeId, command.RequirementDefinitionId, token); async Task <bool> NotBeAVoidedRequirementDefinitionAsync(int requirementDefinitionId, CancellationToken token) => !await requirementDefinitionValidator.IsVoidedAsync(requirementDefinitionId, token); bool HaveAValidRowVersion(string rowVersion) => rowVersionValidator.IsValid(rowVersion); }
public TagValidator(IReadOnlyContext context, IRequirementDefinitionValidator requirementDefinitionValidator) { _context = context; _requirementDefinitionValidator = requirementDefinitionValidator; }
public UpdateRequirementDefinitionCommandValidator( IRequirementTypeValidator requirementTypeValidator, IRequirementDefinitionValidator requirementDefinitionValidator, IFieldValidator fieldValidator) { CascadeMode = CascadeMode.Stop; RuleFor(command => command) .MustAsync(BeAnExistingRequirementDefinitionAsync) .WithMessage(command => "Requirement type and/or requirement definition doesn't exist!") .MustAsync((command, token) => NotBeAVoidedRequirementDefinitionAsync(command.RequirementDefinitionId, token)) .WithMessage(command => $"Requirement definition is voided! Requirement definition={command.Title}") .MustAsync(RequirementDefinitionTitleMustBeUniqueOnType) .WithMessage(command => $"A requirement definition with this title already exists on the requirement type! Requirement type={command.Title}") .MustAsync((command, token) => AllFieldsToBeDeletedAreVoidedAsync(command.RequirementDefinitionId, command.UpdateFields, token)) .WithMessage(command => $"Fields to be deleted must be voided! Requirement definition={command.Title}") .MustAsync((command, token) => NoFieldsToBeDeletedShouldBeInUseAsync(command.RequirementDefinitionId, command.UpdateFields, token)) .WithMessage(command => $"Fields to be deleted can not be in use! Requirement definition={command.Title}"); RuleForEach(command => command.UpdateFields) .MustAsync((command, field, __, token) => BeAnExistingField(command, field.Id, token)) .WithMessage(command => "Field doesn't exist in requirement!") .MustAsync((command, field, __, token) => BeSameFieldTypeOnExistingFieldsAsync(field, token)) .WithMessage((_, field) => $"Cannot change field type on existing fields! Field={field.Id}"); async Task <bool> BeAnExistingRequirementDefinitionAsync(UpdateRequirementDefinitionCommand command, CancellationToken token) => await requirementTypeValidator.RequirementDefinitionExistsAsync(command.RequirementTypeId, command.RequirementDefinitionId, token); async Task <bool> NotBeAVoidedRequirementDefinitionAsync(int requirementDefinitionId, CancellationToken token) => !await requirementDefinitionValidator.IsVoidedAsync(requirementDefinitionId, token); async Task <bool> RequirementDefinitionTitleMustBeUniqueOnType( UpdateRequirementDefinitionCommand command, CancellationToken token) { var fieldTypesFromUpdated = command.UpdateFields.Select(uf => uf.FieldType).ToList(); var fieldTypesFromNew = command.NewFields.Select(nf => nf.FieldType).ToList(); return(!await requirementTypeValidator.OtherRequirementDefinitionExistsWithSameTitleAsync( command.RequirementTypeId, command.RequirementDefinitionId, command.Title, fieldTypesFromUpdated.Concat(fieldTypesFromNew).Distinct().ToList(), token)); } async Task <bool> BeAnExistingField(UpdateRequirementDefinitionCommand command, int fieldId, CancellationToken token) => await requirementTypeValidator.FieldExistsAsync(command.RequirementTypeId, command.RequirementDefinitionId, fieldId, token); async Task <bool> BeSameFieldTypeOnExistingFieldsAsync(UpdateFieldsForCommand field, CancellationToken token) => await fieldValidator.VerifyFieldTypeAsync(field.Id, field.FieldType, token); async Task <bool> AllFieldsToBeDeletedAreVoidedAsync(int requirementDefinitionId, IList <UpdateFieldsForCommand> updateFields, CancellationToken token) { var updateFieldIds = updateFields.Select(u => u.Id).ToList(); return(await requirementDefinitionValidator.AllExcludedFieldsAreVoidedAsync(requirementDefinitionId, updateFieldIds, token)); } async Task <bool> NoFieldsToBeDeletedShouldBeInUseAsync(int requirementDefinitionId, IList <UpdateFieldsForCommand> updateFields, CancellationToken token) { var updateFieldIds = updateFields.Select(u => u.Id).ToList(); return(!await requirementDefinitionValidator.AnyExcludedFieldsIsInUseAsync(requirementDefinitionId, updateFieldIds, token)); } }
public CreateAreaTagCommandValidator( ITagValidator tagValidator, IStepValidator stepValidator, IProjectValidator projectValidator, IRequirementDefinitionValidator requirementDefinitionValidator) { CascadeMode = CascadeMode.Stop; WhenAsync((command, token) => BeASupplierStepAsync(command.StepId, token), () => { RuleFor(command => command) .MustAsync((command, token) => RequirementUsageIsForAllJourneysAsync(command.Requirements, token)) .WithMessage(_ => "Requirements must include requirements to be used both for supplier and other than suppliers!") .When(command => command.TagType != TagType.PoArea, ApplyConditionTo.CurrentValidator) .MustAsync((command, token) => RequirementUsageIsForSupplierAsync(command.Requirements, token)) .WithMessage(_ => "Requirements must include requirements to be used for supplier!") .When(command => command.TagType == TagType.PoArea, ApplyConditionTo.CurrentValidator) .MustAsync((command, token) => RequirementUsageIsNotForOtherThanSupplierAsync(command.Requirements, token)) .WithMessage(_ => "Requirements can not include requirements for other than suppliers!") .When(command => command.TagType == TagType.PoArea, ApplyConditionTo.CurrentValidator); }).Otherwise(() => { RuleFor(command => command) .Must(command => command.TagType != TagType.PoArea) .WithMessage(_ => $"Step for a {TagType.PoArea.GetTagNoPrefix()} tag needs to be for supplier!") .MustAsync((command, token) => RequirementUsageIsForJourneysWithoutSupplierAsync(command.Requirements, token)) .WithMessage(_ => "Requirements must include requirements to be used for other than suppliers!") .MustAsync((command, token) => RequirementUsageIsNotForSupplierOnlyAsync(command.Requirements, token)) .WithMessage(_ => "Requirements can not include requirements just for suppliers!"); }); RuleFor(command => command) .Must(command => BeUniqueRequirements(command.Requirements)) .WithMessage(_ => "Requirement definitions must be unique!") .MustAsync((command, token) => NotBeAnExistingAndClosedProjectAsync(command.ProjectName, token)) .WithMessage(command => $"Project is closed! Project={command.ProjectName}") .MustAsync((command, token) => NotBeAnExistingTagWithinProjectAsync(command.GetTagNo(), command.ProjectName, token)) .WithMessage(command => $"Tag already exists in scope for project! Tag={command.GetTagNo()}") .MustAsync((command, token) => BeAnExistingStepAsync(command.StepId, token)) .WithMessage(command => $"Step doesn't exist! Step={command.StepId}") .MustAsync((command, token) => NotBeAVoidedStepAsync(command.StepId, token)) .WithMessage(command => $"Step is voided! Step={command.StepId}"); RuleForEach(command => command.Requirements) .MustAsync((_, req, _, token) => BeAnExistingRequirementDefinitionAsync(req, token)) .WithMessage((_, req) => $"Requirement definition doesn't exist! Requirement definition={req.RequirementDefinitionId}") .MustAsync((_, req, _, token) => NotBeAVoidedRequirementDefinitionAsync(req, token)) .WithMessage((_, req) => $"Requirement definition is voided! Requirement definition={req.RequirementDefinitionId}"); bool BeUniqueRequirements(IEnumerable <RequirementForCommand> requirements) { var reqIds = requirements.Select(dto => dto.RequirementDefinitionId).ToList(); return(reqIds.Distinct().Count() == reqIds.Count); } async Task <bool> RequirementUsageIsForAllJourneysAsync(IEnumerable <RequirementForCommand> requirements, CancellationToken token) { var reqIds = requirements.Select(dto => dto.RequirementDefinitionId).ToList(); return(await requirementDefinitionValidator.UsageCoversBothForSupplierAndOtherAsync(reqIds, token)); } async Task <bool> RequirementUsageIsForSupplierAsync(IEnumerable <RequirementForCommand> requirements, CancellationToken token) { var reqIds = requirements.Select(dto => dto.RequirementDefinitionId).ToList(); return(await requirementDefinitionValidator.UsageCoversForSuppliersAsync(reqIds, token)); } async Task <bool> RequirementUsageIsForJourneysWithoutSupplierAsync(IEnumerable <RequirementForCommand> requirements, CancellationToken token) { var reqIds = requirements.Select(dto => dto.RequirementDefinitionId).ToList(); return(await requirementDefinitionValidator.UsageCoversForOtherThanSuppliersAsync(reqIds, token)); } async Task <bool> RequirementUsageIsNotForOtherThanSupplierAsync(IEnumerable <RequirementForCommand> requirements, CancellationToken token) { var reqIds = requirements.Select(dto => dto.RequirementDefinitionId).ToList(); return(!await requirementDefinitionValidator.HasAnyForForOtherThanSuppliersUsageAsync(reqIds, token)); } async Task <bool> RequirementUsageIsNotForSupplierOnlyAsync(IEnumerable <RequirementForCommand> requirements, CancellationToken token) { var reqIds = requirements.Select(dto => dto.RequirementDefinitionId).ToList(); return(!await requirementDefinitionValidator.HasAnyForSupplierOnlyUsageAsync(reqIds, token)); } async Task <bool> NotBeAnExistingAndClosedProjectAsync(string projectName, CancellationToken token) => !await projectValidator.IsExistingAndClosedAsync(projectName, token); async Task <bool> NotBeAnExistingTagWithinProjectAsync(string tagNo, string projectName, CancellationToken token) => !await tagValidator.ExistsAsync(tagNo, projectName, token); async Task <bool> BeAnExistingStepAsync(int stepId, CancellationToken token) => await stepValidator.ExistsAsync(stepId, token); async Task <bool> NotBeAVoidedStepAsync(int stepId, CancellationToken token) => !await stepValidator.IsVoidedAsync(stepId, token); async Task <bool> BeASupplierStepAsync(int stepId, CancellationToken token) => await stepValidator.IsForSupplierAsync(stepId, token); async Task <bool> BeAnExistingRequirementDefinitionAsync(RequirementForCommand requirement, CancellationToken token) => await requirementDefinitionValidator.ExistsAsync(requirement.RequirementDefinitionId, token); async Task <bool> NotBeAVoidedRequirementDefinitionAsync(RequirementForCommand requirement, CancellationToken token) => !await requirementDefinitionValidator.IsVoidedAsync(requirement.RequirementDefinitionId, token); }
public UpdateTagStepAndRequirementsCommandValidator( IProjectValidator projectValidator, ITagValidator tagValidator, IStepValidator stepValidator, IRequirementDefinitionValidator requirementDefinitionValidator, IRowVersionValidator rowVersionValidator) { CascadeMode = CascadeMode.Stop; WhenAsync((command, token) => IsASupplierStepAsync(command.StepId, token), () => { WhenAsync((command, token) => NotBeAPoAreaTagAsync(command.TagId, token), () => { RuleFor(command => command) .MustAsync((_, command, token) => RequirementUsageIsForAllJourneysAsync( command.TagId, command.UpdatedRequirements.Where(u => !u.IsVoided).Select(u => u.TagRequirementId).ToList(), command.UpdatedRequirements.Where(u => u.IsVoided).Select(u => u.TagRequirementId).ToList(), command.NewRequirements.Select(r => r.RequirementDefinitionId).ToList(), token)) .WithMessage(_ => "Requirements must include requirements to be used both for supplier and other than suppliers!"); }).Otherwise(() => { RuleFor(command => command) .MustAsync((_, command, token) => RequirementUsageIsForSupplierAsync( command.TagId, command.UpdatedRequirements.Where(u => !u.IsVoided).Select(u => u.TagRequirementId).ToList(), command.UpdatedRequirements.Where(u => u.IsVoided).Select(u => u.TagRequirementId).ToList(), command.NewRequirements.Select(r => r.RequirementDefinitionId).ToList(), token)) .WithMessage(_ => "Requirements must include requirements to be used for supplier!") .MustAsync((command, token) => RequirementUsageIsNotForOtherThanSupplierAsync( command.TagId, command.UpdatedRequirements.Where(u => !u.IsVoided).Select(u => u.TagRequirementId).ToList(), command.UpdatedRequirements.Where(u => u.IsVoided).Select(u => u.TagRequirementId).ToList(), command.NewRequirements.Select(r => r.RequirementDefinitionId).ToList(), token)) .WithMessage(_ => "Requirements can not include requirements for other than suppliers!"); }); }).Otherwise(() => { RuleFor(command => command) .MustAsync((command, token) => NotBeAPoAreaTagAsync(command.TagId, token)) .WithMessage(_ => $"Step for a {TagType.PoArea.GetTagNoPrefix()} tag needs to be for supplier!") .MustAsync((_, command, token) => RequirementUsageIsForJourneysWithoutSupplierAsync( command.TagId, command.UpdatedRequirements.Where(u => !u.IsVoided).Select(u => u.TagRequirementId).ToList(), command.UpdatedRequirements.Where(u => u.IsVoided).Select(u => u.TagRequirementId).ToList(), command.NewRequirements.Select(r => r.RequirementDefinitionId).ToList(), token)) .WithMessage(_ => "Requirements must include requirements to be used for other than suppliers!"); }); WhenAsync((command, token) => IsAnAreaTagAsync(command.TagId, token), () => { RuleFor(command => command) .Must(command => !string.IsNullOrEmpty(command.Description)) .WithMessage(_ => "Description can not be blank!"); }).Otherwise(() => { RuleFor(command => command) .MustAsync((command, token) => NotChangeDescriptionAsync(command.TagId, command.Description, token)) .WithMessage(_ => "Tag must be an area tag to update description!"); }); RuleFor(command => command) .MustAsync((_, command, token) => RequirementsMustBeUniqueAfterUpdateAsync( command.TagId, command.NewRequirements.Select(r => r.RequirementDefinitionId).ToList(), token)) .WithMessage(_ => "Requirements must be unique!") .MustAsync((command, token) => NotBeAClosedProjectForTagAsync(command.TagId, token)) .WithMessage(command => $"Project for tag is closed! Tag={command.TagId}") .MustAsync((command, token) => BeAnExistingTagAsync(command.TagId, token)) .WithMessage(command => $"Tag doesn't exist! Tag={command.TagId}") .MustAsync((command, token) => NotBeAVoidedTagAsync(command.TagId, token)) .WithMessage(command => $"Tag is voided! Tag={command.TagId}") .MustAsync((command, token) => NotChangedToAVoidedStepAsync(command.TagId, command.StepId, token)) .WithMessage(command => $"Step is voided! Step={command.StepId}") .Must(command => HaveAValidRowVersion(command.RowVersion)) .WithMessage(command => $"Not a valid row version! Row version={command.RowVersion}"); RuleForEach(command => command.UpdatedRequirements) .MustAsync((command, req, _, token) => BeAnExistingTagRequirementAsync(command.TagId, req.TagRequirementId, token)) .WithMessage((_, req) => $"Requirement doesn't exist! Requirement={req.TagRequirementId}"); RuleForEach(command => command.DeletedRequirements) .MustAsync((command, req, _, token) => BeAnExistingTagRequirementAsync(command.TagId, req.TagRequirementId, token)) .WithMessage((_, req) => $"Requirement doesn't exist! Requirement={req.TagRequirementId}") .MustAsync((command, req, _, token) => BeAVoidedTagRequirementAsync( command.TagId, req.TagRequirementId, command.UpdatedRequirements.Where(u => u.IsVoided).Select(u => u.TagRequirementId).ToList(), token)) .WithMessage((_, req) => $"Requirement is not voided! Requirement={req.TagRequirementId}"); RuleForEach(command => command.NewRequirements) .MustAsync((_, req, _, token) => BeAnExistingRequirementDefinitionAsync(req.RequirementDefinitionId, token)) .WithMessage((_, req) => $"Requirement definition doesn't exist! Requirement definition={req.RequirementDefinitionId}") .MustAsync((_, req, _, token) => NotBeAVoidedRequirementDefinitionAsync(req.RequirementDefinitionId, token)) .WithMessage((_, req) => $"Requirement definition is voided! Requirement definition={req.RequirementDefinitionId}"); async Task <bool> RequirementsMustBeUniqueAfterUpdateAsync( int tagId, List <int> requirementDefinitionIdsToBeAdded, CancellationToken token) => requirementDefinitionIdsToBeAdded.Count == 0 || await tagValidator.AllRequirementsWillBeUniqueAsync(tagId, requirementDefinitionIdsToBeAdded, token); async Task <bool> RequirementUsageIsNotForOtherThanSupplierAsync( int tagId, List <int> tagRequirementIdsToBeUnvoided, List <int> tagRequirementIdsToBeVoided, List <int> requirementDefinitionIdsToBeAdded, CancellationToken token) => !await tagValidator.RequirementHasAnyForOtherThanSuppliersUsageAsync( tagId, tagRequirementIdsToBeUnvoided, tagRequirementIdsToBeVoided, requirementDefinitionIdsToBeAdded, token); async Task <bool> RequirementUsageIsForSupplierAsync( int tagId, List <int> tagRequirementIdsToBeUnvoided, List <int> tagRequirementIdsToBeVoided, List <int> requirementDefinitionIdsToBeAdded, CancellationToken token) => await tagValidator.RequirementUsageWillCoverForSuppliersAsync( tagId, tagRequirementIdsToBeUnvoided, tagRequirementIdsToBeVoided, requirementDefinitionIdsToBeAdded, token); async Task <bool> RequirementUsageIsForAllJourneysAsync( int tagId, List <int> tagRequirementIdsToBeUnvoided, List <int> tagRequirementIdsToBeVoided, List <int> requirementDefinitionIdsToBeAdded, CancellationToken token) => await tagValidator.RequirementUsageWillCoverBothForSupplierAndOtherAsync( tagId, tagRequirementIdsToBeUnvoided, tagRequirementIdsToBeVoided, requirementDefinitionIdsToBeAdded, token); async Task <bool> RequirementUsageIsForJourneysWithoutSupplierAsync( int tagId, List <int> tagRequirementIdsToBeUnvoided, List <int> tagRequirementIdsToBeVoided, List <int> requirementDefinitionIdsToBeAdded, CancellationToken token) => await tagValidator.RequirementUsageWillCoverForOtherThanSuppliersAsync( tagId, tagRequirementIdsToBeUnvoided, tagRequirementIdsToBeVoided, requirementDefinitionIdsToBeAdded, token); async Task <bool> IsASupplierStepAsync(int stepId, CancellationToken token) => await stepValidator.IsForSupplierAsync(stepId, token); async Task <bool> NotBeAClosedProjectForTagAsync(int tagId, CancellationToken token) => !await projectValidator.IsClosedForTagAsync(tagId, token); async Task <bool> IsAnAreaTagAsync(int tagId, CancellationToken token) => await tagValidator.VerifyTagIsAreaTagAsync(tagId, token); async Task <bool> BeAnExistingTagAsync(int tagId, CancellationToken token) => await tagValidator.ExistsAsync(tagId, token); async Task <bool> NotBeAVoidedTagAsync(int tagId, CancellationToken token) => !await tagValidator.IsVoidedAsync(tagId, token); async Task <bool> NotBeAPoAreaTagAsync(int tagId, CancellationToken token) => !await tagValidator.VerifyTagTypeAsync(tagId, TagType.PoArea, token); async Task <bool> NotChangedToAVoidedStepAsync(int tagId, int stepId, CancellationToken token) => await tagValidator.HasStepAsync(tagId, stepId, token) || !await stepValidator.IsVoidedAsync(stepId, token); async Task <bool> BeAnExistingRequirementDefinitionAsync(int requirementDefinitionId, CancellationToken token) => await requirementDefinitionValidator.ExistsAsync(requirementDefinitionId, token); async Task <bool> NotBeAVoidedRequirementDefinitionAsync(int requirementDefinitionId, CancellationToken token) => !await requirementDefinitionValidator.IsVoidedAsync(requirementDefinitionId, token); async Task <bool> BeAnExistingTagRequirementAsync(int tagId, int tagRequirementId, CancellationToken token) => await tagValidator.HasRequirementAsync(tagId, tagRequirementId, token); async Task <bool> BeAVoidedTagRequirementAsync( int tagId, int tagRequirementId, List <int> tagRequirementIdsToBeVoided, CancellationToken token) { if (tagRequirementIdsToBeVoided.Contains(tagRequirementId)) { return(true); } return(await tagValidator.IsRequirementVoidedAsync(tagId, tagRequirementId, token)); } bool HaveAValidRowVersion(string rowVersion) => rowVersionValidator.IsValid(rowVersion); async Task <bool> NotChangeDescriptionAsync(int tagId, string description, CancellationToken token) => description == null || await tagValidator.VerifyTagDescriptionAsync(tagId, description, token); }