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()); }
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)); }
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); } }