コード例 #1
0
        public ResponseBag <int> Update(EMarca entity)
        {
            // Apply the validations rules to entity.
            var validations = _validationUpdateFactory.Create();

            foreach (var validation in validations)
            {
                var result = validation.Validate(entity);
                if (!result.IsValid)
                {
                    return(new ResponseBag <int>
                    {
                        Ok = false,
                        Message = string.Join(", ", result.Errors)
                    });
                }
            }

            // Save the marca in database.
            var affectedRows = _repository.Update(entity);

            return(new ResponseBag <int>
            {
                Ok = true,
                ObjectResponse = affectedRows
            });
        }
コード例 #2
0
        public ResponseBag <int> Create(EPatrimonio entity)
        {
            // Apply the validations rules to entity.
            var validations = _validationInsertFactory.Create();

            foreach (var validation in validations)
            {
                var result = validation.Validate(entity);
                if (!result.IsValid)
                {
                    return(new ResponseBag <int>
                    {
                        Ok = false,
                        Message = string.Join(", ", result.Errors)
                    });
                }
            }

            // Apply the business rules.
            var rules = _bizRulesInsertFactory.Create();

            foreach (var rule in rules)
            {
                rule.Apply(entity);
            }

            // Save the patrimônio in database.
            var affectedRows = _repository.Create(entity);

            return(new ResponseBag <int>
            {
                Ok = true,
                ObjectResponse = affectedRows
            });
        }