예제 #1
0
		/// <summary>
		/// Returns empty BusinessRuleCollection indicating that the actor has permissions to fetch the data requested.
		/// </summary>
		/// <param name="actor">Actor whose data-access permissions are to be checked.</param>
		/// <returns>Collection of permissions (broken rules) that the actor has failed.</returns>
		/// <remarks>Override in derived classes to add security checks.</remarks>
		public virtual BusinessRuleCollection GrantFetch(IActor actor)
		{
    	BusinessRuleCollection rules = new BusinessRuleCollection();
      BusinessRule rule = new BusinessRule("Entity_GrantFetch", actor.HasPermission(Permissions.CustomerAddress_Read), "Fetch denied on this object.", 1);

      rules.Add(rule);
			return rules;
		}
		/// <summary>
		/// Returns empty BusinessRuleCollection indicating that the actor has permissions to save the current object.
		/// </summary>
		/// <param name="actor">Actor whose data-access permissions are to be checked.</param>
		/// <returns>Collection of permissions (broken rules) that the actor has failed.</returns>
		/// <remarks>Override in derived classes to add security checks.</remarks>
		public virtual BusinessRuleCollection GrantSave(IActor actor)
		{
    	BusinessRuleCollection rules = new BusinessRuleCollection();
      BusinessRule rule = new BusinessRule("Entity_GrantSave", actor.HasPermission(Permissions.ProductModelProductDescription_Update), "Update denied on this object.", 1);

      rules.Add(rule);
			return rules;
		}
예제 #3
0
		/// <summary>
		/// Returns empty BusinessRuleCollection indicating that the actor has permissions to save the current object.
		/// </summary>
		/// <param name="actor">Actor whose data-access permissions are to be checked.</param>
		/// <returns>Collection of permissions (broken rules) that the actor has failed.</returns>
		/// <remarks>Override in derived classes to add security checks.</remarks>
		public virtual BusinessRuleCollection GrantSave(IActor actor)
		{
    	BusinessRuleCollection rules = new BusinessRuleCollection();
      BusinessRule rule = new BusinessRule("Entity_GrantSave", actor.HasPermission(Permissions.CustomerAddress_Update), "Update denied on this object.", 1);

      rules.Add(rule);
			return rules;
		}
예제 #4
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();
		}
예제 #5
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();
		}
예제 #6
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();
		}
예제 #7
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();
		}
예제 #8
0
		/// <summary>
		/// Returns empty BusinessRuleCollection indicating that the actor has permissions to create the current object.
		/// </summary>
		/// <param name="actor">Actor whose data-access permissions are to be checked.</param>
		/// <returns>Collection of permissions (broken rules) that the actor has failed.</returns>
		/// <remarks>Override in derived classes to add security checks.</remarks>
		public virtual BusinessRuleCollection GrantCreate(IActor actor)
		{
    	BusinessRuleCollection rules = new BusinessRuleCollection();
      BusinessRule rule = new BusinessRule("Entity_GrantCreate", actor.HasPermission(Permissions.Address_Insert), "Create denied on this object.", 1);

      rules.Add(rule);
			return rules;
		}
예제 #9
0
		protected virtual void ValidateChildren(BusinessRuleCollection rules, ValidationLevel level)
		{
			rules.Add(ValidateSalesOrderDetailChildren(level));
		}
예제 #10
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();
		}
예제 #11
0
		protected virtual void ValidateChildren(BusinessRuleCollection rules, ValidationLevel level)
		{
			rules.Add(ValidateCustomerAddressChildren(level));
			rules.Add(ValidateSalesOrderHeaderChildren(level));
			rules.Add(ValidateSalesOrderHeaderChildren2(level));
		}
예제 #12
0
		/// <summary>
		/// Returns empty BusinessRuleCollection indicating that the actor has permissions to delete the data requested.
		/// </summary>
		/// <param name="actor">Actor whose data-access permissions are to be checked.</param>
		/// <returns>Collection of permissions (broken rules) that the actor has failed.</returns>
		/// <remarks>Override in derived classes to add security checks.</remarks>
		public virtual BusinessRuleCollection GrantDelete(IActor actor)
		{
    	BusinessRuleCollection rules = new BusinessRuleCollection();
      BusinessRule rule = new BusinessRule("Entity_GrantDelete", actor.HasPermission(Permissions.SalesOrderDetail_Delete), "Delete denied on this object.", 1);

      rules.Add(rule);
			return rules;
		}
예제 #13
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();
		}
예제 #14
0
		protected virtual void ValidateChildren(BusinessRuleCollection rules, ValidationLevel level)
		{
			rules.Add(ValidateProductChildren(level));
			rules.Add(ValidateProductCategoryChildren(level));
		}
예제 #15
0
		protected virtual void ValidateChildren(BusinessRuleCollection rules, ValidationLevel level)
		{
			rules.Add(ValidateProductModelProductDescriptionChildren(level));
		}
예제 #16
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();
		}
예제 #17
0
        /// <summary>
        /// Searches the collection for broken rules and returns them.
        /// </summary>
        /// <returns>A collection of broken rules.</returns>
        public BusinessRuleCollection GetBrokenRules()
        {
            var brokenRules = new BusinessRuleCollection();
            foreach (IBusinessRule rule in this.list)
                if (!rule.IsObeyed)
                    brokenRules.Add(rule);

            return brokenRules;
        }