public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            if (obj == this)
            {
                return(true);
            }

            return(obj is BankAccount other &&
                   ((Id == null && other.Id == null) || (Id?.Equals(other.Id) == true)) &&
                   ((AccountNumberSuffix == null && other.AccountNumberSuffix == null) || (AccountNumberSuffix?.Equals(other.AccountNumberSuffix) == true)) &&
                   ((Country == null && other.Country == null) || (Country?.Equals(other.Country) == true)) &&
                   ((Currency == null && other.Currency == null) || (Currency?.Equals(other.Currency) == true)) &&
                   ((AccountType == null && other.AccountType == null) || (AccountType?.Equals(other.AccountType) == true)) &&
                   ((HolderName == null && other.HolderName == null) || (HolderName?.Equals(other.HolderName) == true)) &&
                   ((PrimaryBankIdentificationNumber == null && other.PrimaryBankIdentificationNumber == null) || (PrimaryBankIdentificationNumber?.Equals(other.PrimaryBankIdentificationNumber) == true)) &&
                   ((SecondaryBankIdentificationNumber == null && other.SecondaryBankIdentificationNumber == null) || (SecondaryBankIdentificationNumber?.Equals(other.SecondaryBankIdentificationNumber) == true)) &&
                   ((DebitMandateReferenceId == null && other.DebitMandateReferenceId == null) || (DebitMandateReferenceId?.Equals(other.DebitMandateReferenceId) == true)) &&
                   ((ReferenceId == null && other.ReferenceId == null) || (ReferenceId?.Equals(other.ReferenceId) == true)) &&
                   ((LocationId == null && other.LocationId == null) || (LocationId?.Equals(other.LocationId) == true)) &&
                   ((Status == null && other.Status == null) || (Status?.Equals(other.Status) == true)) &&
                   Creditable.Equals(other.Creditable) &&
                   Debitable.Equals(other.Debitable) &&
                   ((Fingerprint == null && other.Fingerprint == null) || (Fingerprint?.Equals(other.Fingerprint) == true)) &&
                   ((Version == null && other.Version == null) || (Version?.Equals(other.Version) == true)) &&
                   ((BankName == null && other.BankName == null) || (BankName?.Equals(other.BankName) == true)));
        }
Beispiel #2
0
        public bool IsValid()
        {
            HolderDocument.ClearStrings();

            if (Brand.IsNullOrWhiteSpace())
            {
                throw new ArgumentException("Bandeira do cartão de crédito não informada");
            }

            if (ExpirationMonth.IsNullOrWhiteSpace())
            {
                throw new ArgumentException("Mês de expiração do cartão de crédito não informado");
            }

            int monthAsInt;

            int.TryParse(ExpirationMonth, out monthAsInt);

            if (monthAsInt < 1 || monthAsInt > 12)
            {
                throw new ArgumentException("Mês de expiração do cartão de crédito inválido");
            }

            if (ExpirationYear.IsNullOrWhiteSpace())
            {
                throw new ArgumentException("Ano de expiração do cartão de crédito não informado");
            }

            int yearAsInt;

            int.TryParse(ExpirationYear, out yearAsInt);

            if (yearAsInt < DateTime.Now.Year)
            {
                throw new ArgumentException("Ano de expiração do cartão de crédito inválido");
            }

            if (monthAsInt < DateTime.Now.Month && yearAsInt == DateTime.Now.Year)
            {
                throw new ArgumentException("Mês de expiração do cartão de crédito inválido");
            }

            if (HolderName.IsNullOrWhiteSpace())
            {
                throw new ArgumentException("Nome do titular do cartão de crédito não informado");
            }

            if (HolderDocument.IsNullOrWhiteSpace())
            {
                throw new ArgumentException("Documento do titular do cartão de crédito não informado");
            }

            if (!HolderDocument.IsValidCPF() && !HolderDocument.IsValidCNPJ())
            {
                throw new ArgumentException("Documento do titular do cartão de crédito inválido");
            }

            if (Bin.IsNullOrWhiteSpace())
            {
                throw new ArgumentException("Bin do cartão de crédito não informado");
            }

            if (LastDigits.IsNullOrWhiteSpace())
            {
                throw new ArgumentException("Últimos 4 dígitos do cartão de crédito não informados");
            }

            if (Signature.IsNullOrWhiteSpace())
            {
                throw new ArgumentException("Assinatura do cartão de crédito não informada");
            }

            if (Timestamp.IsNull() || Timestamp == DateTime.MinValue)
            {
                throw new ArgumentException("Timestamp do cartão de crédito não informados");
            }

            if (Token.IsNullOrWhiteSpace())
            {
                throw new ArgumentException("Token do cartão de crédito não informado");
            }

            return(true);
        }
        public override int GetHashCode()
        {
            int hashCode = 424336074;

            if (Id != null)
            {
                hashCode += Id.GetHashCode();
            }

            if (AccountNumberSuffix != null)
            {
                hashCode += AccountNumberSuffix.GetHashCode();
            }

            if (Country != null)
            {
                hashCode += Country.GetHashCode();
            }

            if (Currency != null)
            {
                hashCode += Currency.GetHashCode();
            }

            if (AccountType != null)
            {
                hashCode += AccountType.GetHashCode();
            }

            if (HolderName != null)
            {
                hashCode += HolderName.GetHashCode();
            }

            if (PrimaryBankIdentificationNumber != null)
            {
                hashCode += PrimaryBankIdentificationNumber.GetHashCode();
            }

            if (SecondaryBankIdentificationNumber != null)
            {
                hashCode += SecondaryBankIdentificationNumber.GetHashCode();
            }

            if (DebitMandateReferenceId != null)
            {
                hashCode += DebitMandateReferenceId.GetHashCode();
            }

            if (ReferenceId != null)
            {
                hashCode += ReferenceId.GetHashCode();
            }

            if (LocationId != null)
            {
                hashCode += LocationId.GetHashCode();
            }

            if (Status != null)
            {
                hashCode += Status.GetHashCode();
            }
            hashCode += Creditable.GetHashCode();
            hashCode += Debitable.GetHashCode();

            if (Fingerprint != null)
            {
                hashCode += Fingerprint.GetHashCode();
            }

            if (Version != null)
            {
                hashCode += Version.GetHashCode();
            }

            if (BankName != null)
            {
                hashCode += BankName.GetHashCode();
            }

            return(hashCode);
        }