public ResponseObject <ClientForGetDto> Update(ClientForUpdateDto clientForUpdateDto) { if (!ValidateCPF.IsCpf(clientForUpdateDto.SocialSecurityNumber)) { return(new ResponseObject <ClientForGetDto>(false, "CPF Inválido")); } var occupationForCheckId = _occupationRepository.GetById(clientForUpdateDto.IdOccupation); if (occupationForCheckId == null) { return(new ResponseObject <ClientForGetDto>(false, "Não existe um cargo com o ID informado")); } var clientForCheckId = _clientRepository.GetById(clientForUpdateDto.Id); if (clientForCheckId == null) { return(new ResponseObject <ClientForGetDto>(false, "Não existe um usuário com o ID informado")); } var clientForUpdate = _mapper.Map <Client>(clientForUpdateDto); _clientRepository.Update(clientForUpdate); var commit = _unityOfWork.Commit(); return(commit ? new ResponseObject <ClientForGetDto>(true, obj: _mapper.Map <ClientForGetDto>(clientForUpdate)) : new ResponseObject <ClientForGetDto>(false)); }
private List <ErrorsTO> ValidateCpfAsync(ResponsibleRequestTO responsibleRequestTO) { var errors = new List <ErrorsTO>(); if (!ValidateCPF.IsCpf(responsibleRequestTO.Cpf.ToString().PadLeft(11, '0'))) { errors.Add(new ErrorsTO { Field = "CPF", Validation = Messaging.InvalidCPF }); } return(errors); }