Exemple #1
0
        public ValidationFailure CreateCodeValidate(Warning warning, ValidationContext <Warning> context)
        {
            var warningsRetrieved = _warningRepository.FindBy(bran => bran.Code == warning.Code && bran.IsActive);

            if (warningsRetrieved.IsNotEmpty())
            {
                return(new ValidationFailure("Warning", "Ya existe codigo"));
            }

            return(null);
        }
 public SuccessResponse Update(WarningRequest request)
 {
     try
     {
         var currentWarning = _warningRepository.FindBy(request.Id);
         currentWarning.ThrowExceptionIfRecordIsNull();
         var warningToCopy = TypeAdapter.Adapt <Warning>(request);
         TypeAdapter.Adapt(warningToCopy, currentWarning);
         _warningValidator.ValidateAndThrowException(currentWarning, "Base,Update");
         _warningRepository.Update(currentWarning);
         return(new SuccessResponse {
             IsSuccess = true
         });
     }
     catch (DataAccessException)
     {
         throw new ApplicationException();
     }
 }