public UpdateMenuItemValidator(ISiteRules siteRules,
                                IPageRules pageRules,
                                ILanguageRules languageRules,
                                IValidator <MenuItemDetails.MenuItemLocalisation> localisationValidator)
     : base(siteRules, pageRules, languageRules, localisationValidator)
 {
 }
Beispiel #2
0
        public PageLocalisationValidator(IPageRules pageRules, ILanguageRules languageRules)
        {
            _pageRules     = pageRules;
            _languageRules = languageRules;

            RuleFor(c => c.LanguageId)
            .NotEmpty().WithMessage("Language is required.")
            .Must(BeAnExistingLanguage).WithMessage("Language does not exist.");

            RuleFor(c => c.Url)
            .Length(1, 200).WithMessage("Page url cannot have more than 200 characters.")
            .Must(HaveValidUrl).WithMessage("Page url is not valid. Enter only letters, numbers, underscores and hyphens with no spaces.")
            .When(x => !string.IsNullOrWhiteSpace(x.Url));

            RuleFor(c => c.Title)
            .Length(1, 250).WithMessage("Head title cannot have more than 250 characters.")
            .When(x => !string.IsNullOrWhiteSpace(x.Title));

            RuleFor(c => c.MetaDescription)
            .Length(1, 500).WithMessage("Meta description cannot have more than 500 characters.")
            .When(x => !string.IsNullOrWhiteSpace(x.MetaDescription));

            RuleFor(c => c.MetaKeywords)
            .Length(1, 500).WithMessage("Meta keywords cannot have more than 500 characters.")
            .When(x => !string.IsNullOrWhiteSpace(x.MetaKeywords));
        }
Beispiel #3
0
        public MenuItemValidator(ISiteRules siteRules,
                                 IPageRules pageRules,
                                 ILanguageRules languageRules,
                                 IValidator <MenuItemLocalisation> localisationValidator)
            : base(siteRules)
        {
            _pageRules             = pageRules;
            _languageRules         = languageRules;
            _localisationValidator = localisationValidator;

            RuleFor(c => c.PageId)
            .NotEmpty().WithMessage("Page is required.")
            .Must(BeAnExistingPage).WithMessage("Page does not exist.")
            .When(c => c.Type == MenuItemType.Page);

            RuleFor(c => c.Link)
            .NotEmpty().WithMessage("Link is required.")
            .Length(1, 250).WithMessage("Link length must be between 1 and 250 characters.")
            .When(c => c.Type == MenuItemType.Link);

            RuleFor(c => c.Text)
            .NotEmpty().WithMessage("Text is required.")
            .Length(1, 100).WithMessage("Text length must be between 1 and 100 characters.");

            RuleFor(c => c.Title)
            .Length(1, 100).WithMessage("Title length must be between 1 and 100 characters.")
            .When(c => c.Title != string.Empty);

            RuleFor(c => c.MenuItemLocalisations)
            .Must(IncludeAllSupportedLanguages).WithMessage("All supported languages should be included.");

            RuleFor(c => c.MenuItemLocalisations)
            .SetCollectionValidator(_localisationValidator);
        }
Beispiel #4
0
 public UpdatePageDetailsValidator(IPageRules pageRules,
                                   ISiteRules siteRules,
                                   ILanguageRules languageRules,
                                   IValidator <PageLocalisation> localisationValidator)
     : base(pageRules, siteRules, languageRules, localisationValidator)
 {
 }
Beispiel #5
0
 public PageController(IDispatcher dispatcher,
                       IPageRules pageRules,
                       IContextService contextService)
     : base(contextService)
 {
     _dispatcher = dispatcher;
     _pageRules  = pageRules;
 }
 public AddMenuItemValidator(ISiteRules siteRules,
                             IPageRules pageRules,
                             ILanguageRules languageRules,
                             IValidator <MenuItemDetails.MenuItemLocalisation> localisationValidator)
     : base(siteRules, pageRules, languageRules, localisationValidator)
 {
     RuleFor(c => c.MenuItemId)
     .NotEmpty().WithMessage("Menu item id is required.");
 }
Beispiel #7
0
 public PageService(IPageRules pageRules, IUOWFactory dataFactory, IGetUserDTO getUserService, IDTOHelper dtoHelper)
 {
     PageRules      = pageRules;
     DataFactory    = dataFactory;
     GetUserService = getUserService;
     DTOHelper      = dtoHelper;
     //---------------------------
     InitMap();
 }
Beispiel #8
0
 public PageController(ICommandSender commandSender,
     IQueryDispatcher queryDispatcher,           
     IPageRules pageRules,
     IContextService contextService)
     : base(contextService)
 {
     _commandSender = commandSender;
     _pageRules = pageRules;
     _queryDispatcher = queryDispatcher;
 }
        public CreatePageValidator(IPageRules pageRules,
                                   ISiteRules siteRules,
                                   ILanguageRules languageRules,
                                   IValidator <PageLocalisation> localisationValidator)
            : base(pageRules, siteRules, languageRules, localisationValidator)
        {
            _pageRules = pageRules;

            RuleFor(c => c.Id)
            .Must(HaveUniqueId).WithMessage("A page with the same id already exists.")
            .When(x => x.Id != Guid.Empty);
        }
Beispiel #10
0
        public CreatePageValidator(IPageRules pageRules,
                                   ISiteRules siteRules,
                                   ILanguageRules languageRules,
                                   IValidator <PageLocalisation> localisationValidator)
            : base(pageRules, siteRules, languageRules, localisationValidator)
        {
            _pageRules = pageRules;

            RuleFor(c => c.Id)
            .NotEmpty().WithMessage("Id is required.")
            .Must(HaveUniqueId).WithMessage("A page with the same id already exists.");
        }
Beispiel #11
0
        public PageModuleLocalisationValidator(IPageRules pageRules, ILanguageRules languageRules)
        {
            _pageRules     = pageRules;
            _languageRules = languageRules;

            RuleFor(c => c.LanguageId)
            .NotEmpty().WithMessage("Language is required.")
            .Must(BeAnExistingLanguage).WithMessage("Language does not exist.");

            RuleFor(c => c.Title)
            .Length(1, 250).WithMessage("Title cannot have more than 250 characters.")
            .When(x => !string.IsNullOrWhiteSpace(x.Title));
        }
Beispiel #12
0
 public PageController(IPageFacade pageFacade,
                       ICommandSender commandSender,
                       IPageRules pageRules,
                       IPageRepository pageRepository,
                       IRoleService identityService,
                       IContextService contextService)
     : base(contextService)
 {
     _pageFacade      = pageFacade;
     _commandSender   = commandSender;
     _pageRules       = pageRules;
     _pageRepository  = pageRepository;
     _identityService = identityService;
 }
        public PageDetailsValidator(IPageRules pageRules,
                                    ISiteRules siteRules,
                                    ILanguageRules languageRules,
                                    IValidator <PageLocalisation> localisationValidator)
        {
            _pageRules             = pageRules;
            _siteRules             = siteRules;
            _languageRules         = languageRules;
            _localisationValidator = localisationValidator;

            RuleFor(c => c.SiteId)
            .NotEmpty().WithMessage("Site id is required.")
            .Must(BeAnExistingSite).WithMessage("Site does not exist.");

            RuleFor(c => c.Name)
            .NotEmpty().WithMessage("Page name is required.")
            .Length(1, 100).WithMessage("Page name length must be between 1 and 100 characters.")
            .Must(HaveValidName).WithMessage("Page name is not valid. Enter only letters, numbers, underscores and hyphens.")
            .Must(HaveUniqueName).WithMessage("A page with the same name already exists.");

            RuleFor(c => c.Url)
            .NotEmpty().WithMessage("Page url is required.")
            .Length(1, 200).WithMessage("Page url length must be between 1 and 200 characters.")
            .Must(HaveValidUrl).WithMessage("Page url is not valid. Enter only letters, numbers, slashes, underscores and hyphens with no spaces.")
            .Must(NotBeReserved).WithMessage("Page url is reserved.")
            .Must(HaveUniqueUrl).WithMessage("A page with the same url already exists.");

            RuleFor(c => c.Title)
            .Length(1, 250).WithMessage("Head title cannot have more than 250 characters.")
            .When(x => !string.IsNullOrWhiteSpace(x.Title));

            RuleFor(c => c.MetaDescription)
            .Length(1, 500).WithMessage("Meta description cannot have more than 500 characters.")
            .When(x => !string.IsNullOrWhiteSpace(x.MetaDescription));

            RuleFor(c => c.MetaKeywords)
            .Length(1, 500).WithMessage("Meta keywords cannot have more than 500 characters.")
            .When(x => !string.IsNullOrWhiteSpace(x.MetaKeywords));

            RuleFor(c => c.PageLocalisations)
            .Must(IncludeAllSupportedLanguages).WithMessage("All supported languages should be included.");

            RuleFor(c => c.PageLocalisations)
            .SetCollectionValidator(_localisationValidator);
        }