Ejemplo n.º 1
0
        private async Task ValidateIsUniqueAsync(
            UpdateCustomEntityUrlCommand command,
            CustomEntityDefinitionSummary definition,
            IExecutionContext executionContext
            )
        {
            if (!definition.ForceUrlSlugUniqueness)
            {
                return;
            }

            var query = new IsCustomEntityPathUniqueQuery();

            query.CustomEntityDefinitionCode = definition.CustomEntityDefinitionCode;
            query.CustomEntityId             = command.CustomEntityId;
            query.LocaleId = command.LocaleId;
            query.UrlSlug  = command.UrlSlug;

            var isUnique = await _queryExecutor.ExecuteAsync(query, executionContext);

            if (!isUnique)
            {
                var message = string.Format("A {0} already exists with the {2} '{1}'",
                                            definition.Name,
                                            command.UrlSlug,
                                            definition.Terms.GetOrDefault(CustomizableCustomEntityTermKeys.UrlSlug, "url slug").ToLower());
                throw new UniqueConstraintViolationException(message, "UrlSlug", command.UrlSlug);
            }
        }
        private IsCustomEntityPathUniqueQuery GetUniquenessQuery(AddCustomEntityCommand command, CustomEntityDefinitionSummary definition)
        {
            var query = new IsCustomEntityPathUniqueQuery();

            query.CustomEntityDefinitionCode = definition.CustomEntityDefinitionCode;
            query.LocaleId = command.LocaleId;
            query.UrlSlug  = command.UrlSlug;

            return(query);
        }
Ejemplo n.º 3
0
        private IsCustomEntityPathUniqueQuery GetUniquenessQuery(CustomEntityVersion dbVersion, ICustomEntityDefinition definition)
        {
            var query = new IsCustomEntityPathUniqueQuery();

            query.CustomEntityDefinitionCode = definition.CustomEntityDefinitionCode;
            query.LocaleId       = dbVersion.CustomEntity.LocaleId;
            query.UrlSlug        = SlugFormatter.ToSlug(dbVersion.Title);
            query.CustomEntityId = dbVersion.CustomEntityId;

            return(query);
        }
Ejemplo n.º 4
0
 public Task <bool> IsCustomEntityPathUniqueAsync(IsCustomEntityPathUniqueQuery query, IExecutionContext executionContext = null)
 {
     return(_queryExecutor.ExecuteAsync(query));
 }
Ejemplo n.º 5
0
 public bool IsCustomEntityPathUnique(IsCustomEntityPathUniqueQuery query, IExecutionContext executionContext = null)
 {
     return(_queryExecutor.Execute(query));
 }