Exemple #1
0
        public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            var validationResults = new List <ValidationResult>();

            var existingCustomPages = MultiTenantHelpers.GetAllCustomPages();

            if (!CustomPageModelExtensions.IsDisplayNameUnique(existingCustomPages, CustomPageDisplayName, CustomPageID))
            {
                validationResults.Add(new SitkaValidationResult <EditViewModel, string>("Custom Page with the provided Display Name already exists.", x => x.CustomPageDisplayName));
            }

            if (!string.IsNullOrWhiteSpace(CustomPageVanityUrl))
            {
                if (!new Regex("^[a-zA-Z0-9]*$").IsMatch(CustomPageVanityUrl))
                {
                    validationResults.Add(new SitkaValidationResult <EditViewModel, string>("Vanity Url must not contain any special characters or spaces.", x => x.CustomPageVanityUrl));
                }
                else if (!CustomPageModelExtensions.IsVanityUrlUnique(existingCustomPages, CustomPageVanityUrl, CustomPageID))
                {
                    validationResults.Add(new SitkaValidationResult <EditViewModel, string>("A Custom Page with the provided Vanity Url already exists.", x => x.CustomPageVanityUrl));
                }
            }

            return(validationResults);
        }
        public ActionResult About(string vanityUrl)
        {
            var customPage = MultiTenantHelpers.GetAllCustomPages()
                             .SingleOrDefault(x => x.CustomPageVanityUrl == vanityUrl);

            new CustomPageViewFeature().DemandPermission(CurrentPerson, customPage);
            var hasPermission = new CustomPageManageFeature().HasPermission(CurrentPerson, customPage).HasPermission;
            var viewData      = new DisplayPageContentViewData(CurrentPerson, customPage, hasPermission);

            return(RazorView <DisplayPageContent, DisplayPageContentViewData>(viewData));
        }