Пример #1
0
        public RoleCreateFormValidator(
            IRoleStore roleStore,
            IResourceStore resourceStore,
            ICodeRule codeRule,
            IDescriptionRule descriptionRule,
            IDisplayNameRule displayNameRule)
        {
            this.RoleStore     = roleStore;
            this.ResourceStore = resourceStore;

            RuleFor(x => x.Code)
            .NotEmpty()
            .ApplyRule(codeRule)
            .MustAsync(NotBeExistingCodeAsync)
            .WithMessage("Already existing");

            RuleFor(x => x.Name)
            .NotEmpty()
            .ApplyRule(displayNameRule);

            RuleFor(x => x.Description)
            .ApplyRule(descriptionRule);

            RuleFor(x => x.Permissions)
            .Cascade(CascadeMode.StopOnFirstFailure)
            .NotEmpty()
            .MustAsync(BeExistingResourceCodes)
            .WithMessage("Unexisting resource code detected.");
        }
Пример #2
0
 public ResourcesController(
     IResourceStore resourceStore,
     ICodeRule codeRule,
     IDescriptionRule descriptionRule)
 {
     this.ResourceStore   = resourceStore;
     this.CodeRule        = codeRule;
     this.DescriptionRule = descriptionRule;
 }
Пример #3
0
        public ResourceUpdateFormValidator(
            ICodeRule codeRule,
            IDescriptionRule descriptionRule)
        {
            RuleFor(x => x.Category)
            .ApplyRule(codeRule);

            RuleFor(x => x.Description)
            .ApplyRule(descriptionRule);
        }
Пример #4
0
 public RolesController(
     IRoleStore roleStore,
     IResourceStore resourceStore,
     ICodeRule codeRule,
     IDescriptionRule descriptionRule,
     IDisplayNameRule displayNameRule)
 {
     this.RoleStore       = roleStore;
     this.ResourceStore   = resourceStore;
     this.CodeRule        = codeRule;
     this.DescriptionRule = descriptionRule;
     this.DisplayNameRule = displayNameRule;
 }
Пример #5
0
        public ResourceValidator(
            ICodeRule codeRule,
            IDescriptionRule descriptionRule)
        {
            RuleFor(x => x.Code)
            .NotEmpty()
            .ApplyRule(codeRule);

            RuleFor(x => x.Category)
            .NotEmpty()
            .ApplyRule(codeRule);

            RuleFor(x => x.Description)
            .ApplyRule(descriptionRule);
        }
Пример #6
0
        public RoleValidator(
            IResourceStore resourceStore,
            ICodeRule codeRule,
            IDisplayNameRule displayNameRule,
            IDescriptionRule descriptionRule)
        {
            this.ResourceStore = resourceStore;

            RuleFor(x => x.Code)
            .NotEmpty()
            .ApplyRule(codeRule);

            RuleFor(x => x.DisplayName)
            .NotEmpty()
            .ApplyRule(displayNameRule);

            RuleFor(x => x.Description)
            .ApplyRule(descriptionRule);

            RuleFor(x => x.Permissions)
            .NotEmpty()
            .Must(BeUniquePermissionPerResource)
            .MustAsync(BeExistingResourceCodes);
        }