Esempio n. 1
0
        public bool UpdateDocumentType(DocumentTypeDto request)
        {
            ValidateRequireDocumentype(request);
            var documentTypeIdExist = _repoDocumentType
                                      .SearchMatching <DocumentTypeEntity>(dt => dt.DocumentTypeId == request.DocumentTypeId);

            if (!documentTypeIdExist.Any())
            {
                throw new DontExistIdException();
            }
            var entityUpdate = documentTypeIdExist.FirstOrDefault();

            entityUpdate.DocumentType = request.DocumentType;
            return(_repoDocumentType.Update(entityUpdate));
        }
Esempio n. 2
0
        public void ValidateDontHaveDocumentTypeNit(EmployedDto request, IEnumerable <EmployedEntity> people)
        {
            var documentIdExist = _repoDocumentType
                                  .SearchMatching <DocumentTypeEntity>(dt => dt.DocumentTypeId == request.DocumentTypeId);

            if (!documentIdExist.Any())
            {
                throw new NoExistDocumentTypeException();
            }
            var documentIsNit = documentIdExist.Where(x => x.DocumentType.ToLower() == "nit");

            if (documentIsNit.Any())
            {
                throw new CannotBeCorporatePersonException("Una persona no puede tener un tipo de documento Nit");
            }
        }
Esempio n. 3
0
        public void ValidateDontHaveDocumentTypeDiferentNit(ProviderDto request, IEnumerable <ProviderEntity> people)
        {
            var documentIdExist = _repoDocumentType
                                  .SearchMatching <DocumentTypeEntity>(dt => dt.DocumentTypeId == request.DocumentTypeId);

            if (!documentIdExist.Any())
            {
                throw new NoExistDocumentTypeException();
            }
            var documentIsNit = documentIdExist.Where(x => x.DocumentType.ToLower() != "nit");

            if (documentIsNit.Any())
            {
                throw new CannotBeNaturalPersonException("Una persona no puede tener un tipo de documento diferente a Nit");
            }
        }