Exemplo n.º 1
0
        public BusinessRuleResult Execute(IEntity instance)
        {
            var failed           = false;
            var module           = instance as Framework.DomainModel.Entities.Module;
            var validationResult = new List <ValidationResult>();

            if (module != null)
            {
                if (string.IsNullOrEmpty(module.Name))
                {
                    var mess = string.Format(SystemMessageLookup.GetMessage("RequiredTextResourceKey"), "Name");
                    validationResult.Add(new ValidationResult(mess));
                    failed = true;
                }
                if (!string.IsNullOrEmpty(module.Name) && _moduleRepository.CheckExist(o => o.Name == module.Name && o.Id != module.Id))
                {
                    var mess = string.Format(SystemMessageLookup.GetMessage("ExistsTextResourceKey"), "Name");
                    validationResult.Add(new ValidationResult(mess));
                    failed = true;
                }
                var result = new BusinessRuleResult(failed, "", instance.GetType().Name, instance.Id, PropertyNames, Name)
                {
                    ValidationResults = validationResult
                };
                return(result);
            }

            return(new BusinessRuleResult());
        }