示例#1
0
		/// <summary>Validates objec.</summary>
		public virtual BusinessRuleCollection Validate(ValidationLevel level)
		{
				BusinessRuleCollection rules = new BusinessRuleCollection();
				rules.Add(DALHelper.CheckEntityRules(this));
				if (rules.AllRulesAreObeyed && level > ValidationLevel.BasicFieldConstraints)
				    ValidateChildren(rules, level);

				return rules.GetBrokenRules();
		}
示例#2
0
		/// <summary>Saves biz object if actor has required permission and if biz object is valid.</summary>
		public virtual BusinessRuleCollection DeleteIfValid(IActor actor, bool enforceSecurityChecks)
		{
				BusinessRuleCollection rules = new BusinessRuleCollection();

				// Check permissions.
				if (enforceSecurityChecks)
				    rules.Add(GrantDelete(actor));

				if (rules.HasBrokenRules)
				    return rules.GetBrokenRules();

				this.Delete(actor);
				return rules.GetBrokenRules();
		}
示例#3
0
		/// <summary>Saves biz object if actor has required permission and if biz object is valid.</summary>
		public virtual BusinessRuleCollection SaveIfValid(IActor actor, ValidationLevel level, bool enforceSecurityChecks)
		{
				// Validate object.
				BusinessRuleCollection rules = new BusinessRuleCollection();
				rules.Add(Validate(level));
				if (rules.HasBrokenRules)
				    return rules.GetBrokenRules();

				// Check permissions.
				if (enforceSecurityChecks && !this.IsNew)
				    rules.Add(GrantSave(actor));

				if (enforceSecurityChecks && this.IsNew)
				    rules.Add(GrantCreate(actor));

				if (rules.HasBrokenRules)
				    return rules.GetBrokenRules();

				// Save if valid and actor has all required permissions.
				Save(actor);
				return rules.GetBrokenRules();
		}
示例#4
0
		/// <summary>Saves biz object if actor has required permission and if biz object is valid.</summary>
		public virtual BusinessRuleCollection FetchIfValid(IActor actor, DataAccessScope detailLevel, bool enforceSecurityChecks)
		{
				BusinessRuleCollection rules = new BusinessRuleCollection();

				// Check permissions.
				if (enforceSecurityChecks)
				    rules.Add(GrantFetch(actor));

				if (rules.HasBrokenRules)
				    return rules.GetBrokenRules();

				rules.Add(new BusinessRule("Entity_Exists", this.Fetch(actor, detailLevel), "Entity does not exist.", 1));
				return rules.GetBrokenRules();
		}
示例#5
0
		/// <summary>Validates collection SalesOrderHeaderChildren2.</summary>
		protected BusinessRuleCollection ValidateSalesOrderHeaderChildren2(ValidationLevel level)
		{
            BusinessRuleCollection rules = new BusinessRuleCollection();
            SalesOrderHeader.ConvertEntitiesToBusinessObjects(this.SalesOrderHeaderChildren2);
            foreach (IBusinessObject bizobj in this.SalesOrderHeaderChildren2)
                rules.Add(bizobj.Validate(level));

            return rules.GetBrokenRules();
		}
示例#6
0
		/// <summary>Validates collection CustomerAddressChildren.</summary>
		protected BusinessRuleCollection ValidateCustomerAddressChildren(ValidationLevel level)
		{
            BusinessRuleCollection rules = new BusinessRuleCollection();
            CustomerAddress.ConvertEntitiesToBusinessObjects(this.CustomerAddressChildren);
            foreach (IBusinessObject bizobj in this.CustomerAddressChildren)
                rules.Add(bizobj.Validate(level));

            return rules.GetBrokenRules();
		}
示例#7
0
		/// <summary>Validates collection ProductCategoryChildren.</summary>
		protected BusinessRuleCollection ValidateProductCategoryChildren(ValidationLevel level)
		{
            BusinessRuleCollection rules = new BusinessRuleCollection();
            ProductCategory.ConvertEntitiesToBusinessObjects(this.ProductCategoryChildren);
            foreach (IBusinessObject bizobj in this.ProductCategoryChildren)
                rules.Add(bizobj.Validate(level));

            return rules.GetBrokenRules();
		}