Beispiel #1
0
        public InvariantResult IsValid(CreateRule obj)
        {
            ContentTypeKey contentTypeKey = ContentTypeKey.New(obj.TenantId, obj.ContentTypeCode);
            ContentType    contentType    = this.contentTypeRepository.GetById(contentTypeKey).GetAwaiter().GetResult();

            // Validate content type.
            if (contentType == null)
            {
                return(InvariantResult.ForInvalid(this.Code, string.Format(InvariantResources.R004, obj.TenantId, obj.ContentTypeCode)));
            }

            return(InvariantResult.ForValid(this.Code));
        }
        public InvariantResult IsValid(CreateRule obj)
        {
            if (obj.RootCondition != null)
            {
                IEnumerable <string> messages = this.ValidateRecursive(obj.RootCondition, obj.TenantId);

                if (messages.Any())
                {
                    return(InvariantResult.ForInvalid(this.Code, messages.Distinct().ToArray()));
                }
            }

            return(InvariantResult.ForValid(this.Code));
        }
        public InvariantResult IsValid(CreateRule obj)
        {
            // Validate rule interval.
            if (obj.DateEnd.HasValue)
            {
                DateTime dateBegin = obj.DateBegin;
                DateTime dateEnd   = obj.DateEnd.GetValueOrDefault();
                if (dateEnd <= dateBegin)
                {
                    return(InvariantResult.ForInvalid(this.Code, string.Format(InvariantResources.R002, dateBegin, dateEnd)));
                }
            }

            return(InvariantResult.ForValid(this.Code));
        }
        public InvariantResult IsValid(UpdateRule obj)
        {
            // Validate rule interval.
            if (obj.DateEnd.HasValue)
            {
                RuleKey ruleKey = RuleKey.New(obj.TenantId, obj.Id);
                Rule    rule    = this.ruleRepository.GetById(ruleKey).GetAwaiter().GetResult();

                if (rule != null)
                {
                    DateTime dateBegin = rule.DateBegin;
                    DateTime dateEnd   = obj.DateEnd.GetValueOrDefault();
                    if (dateEnd <= dateBegin)
                    {
                        return(InvariantResult.ForInvalid(this.Code, string.Format(InvariantResources.R002, dateBegin, dateEnd)));
                    }
                }
            }

            return(InvariantResult.ForValid(this.Code));
        }