Example #1
0
        public IResult Update(Product product)
        {
            IResult result = BusinessRuleTool.Run(
                _productRuler.RuleCategoryCount(OptionVariables.MaxCategoryCount, product.CategoryId),
                _productRuler.RuleProductNameExists(product.ProductName),
                _productRuler.RuleCategoryLimit(OptionVariables.CategoryEndLimit)
                );

            if (result != null)
            {
                return(result);
            }
            _productDal.Update(product);
            return(new SuccessResult());
        }
Example #2
0
        public IResult Add(Product product)
        {
            IResult result = BusinessRuleTool.Run(
                _productRuler.RuleCategoryCount(OptionVariables.MaxCategoryCount, product.CategoryId),
                _productRuler.RuleProductNameExists(product.ProductName),
                _productRuler.RuleCategoryLimit(OptionVariables.CategoryEndLimit)
                );

            if (result != null)
            {
                return(result);
            }

            //return CheckAllRules(product);
            _productDal.Add(product);
            return(new SuccessResult(Messages.ProductAdded));
        }
Example #3
0
        private IResult CheckAllRules(Product product)
        {
            //trying to methodize this one
            IResult result = BusinessRuleTool.Run(
                _productRuler.RuleCategoryCount(OptionVariables.MaxCategoryCount, product.CategoryId),
                _productRuler.RuleProductNameExists(product.ProductName),
                _productRuler.RuleCategoryLimit(OptionVariables.CategoryEndLimit)
                );

            if (result != null)
            {
                return(result);
            }
            else
            {
                return(null);
            }
        }