public ValidationFailure CreateCodeValidate(Disease disease, ValidationContext <Disease> context)
        {
            var diseasesRetrieved = _diseaseRepository.FindBy(dise => dise.Code == disease.Code && dise.IsActive);

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

            return(null);
        }
        public DTO.Warning Execute(Warning warning)
        {
            var warningDto = TypeAdapter.Adapt <DTO.Warning>(warning);
            var disease    = _diseaseRepository.FindBy(warning.DiseaseId);

            warningDto.Disease = TypeAdapter.Adapt <DTO.Disease>(disease);
            return(warningDto);
        }
예제 #3
0
 public SuccessResponse Update(DiseaseRequest request)
 {
     try
     {
         var currentDisease = _diseaseRepository.FindBy(request.Id);
         currentDisease.ThrowExceptionIfRecordIsNull();
         var diseasToCopy = TypeAdapter.Adapt <Disease>(request);
         TypeAdapter.Adapt(diseasToCopy, currentDisease);
         _diseaseValidator.ValidateAndThrowException(currentDisease, "Base,Update");
         _diseaseRepository.Update(currentDisease);
         return(new SuccessResponse {
             IsSuccess = true
         });
     }
     catch (DataAccessException)
     {
         throw new ApplicationException();
     }
 }
예제 #4
0
        public ValidationFailure ReferencesValidate(Warning warning, ValidationContext <Warning> context)
        {
            var disease = _diseaseRepository.FindBy(warning.DiseaseId);

            if (disease.IsNull() || disease.Status.Equals(GlobalConstants.StatusDeactivated))
            {
                return(new ValidationFailure("Warning", "La enfermedad esta desactivada o no existe"));
            }

            return(null);
        }