Example #1
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (MinPaymentAmount != null)
         {
             hashCode = hashCode * 59 + MinPaymentAmount.GetHashCode();
         }
         if (PaymentDueAmount != null)
         {
             hashCode = hashCode * 59 + PaymentDueAmount.GetHashCode();
         }
         if (PaymentCurrency != null)
         {
             hashCode = hashCode * 59 + PaymentCurrency.GetHashCode();
         }
         if (PaymentDueDate != null)
         {
             hashCode = hashCode * 59 + PaymentDueDate.GetHashCode();
         }
         return(hashCode);
     }
 }
Example #2
0
        /// <summary>
        /// Returns true if BankingCreditCardAccount instances are equal
        /// </summary>
        /// <param name="other">Instance of BankingCreditCardAccount to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(BankingCreditCardAccount other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     MinPaymentAmount == other.MinPaymentAmount ||
                     MinPaymentAmount != null &&
                     MinPaymentAmount.Equals(other.MinPaymentAmount)
                     ) &&
                 (
                     PaymentDueAmount == other.PaymentDueAmount ||
                     PaymentDueAmount != null &&
                     PaymentDueAmount.Equals(other.PaymentDueAmount)
                 ) &&
                 (
                     PaymentCurrency == other.PaymentCurrency ||
                     PaymentCurrency != null &&
                     PaymentCurrency.Equals(other.PaymentCurrency)
                 ) &&
                 (
                     PaymentDueDate == other.PaymentDueDate ||
                     PaymentDueDate != null &&
                     PaymentDueDate.Equals(other.PaymentDueDate)
                 ));
        }
        public ValidatorResult Validate(RegistrationRequest target)
        {
            decimal amount;

            if (!decimal.TryParse(target.PaymentAmount, out amount))
            {
                amount = 0;
            }

            if (amount < MinPaymentAmount || amount > MaxPaymentAmount)
            {
                return(ValidatorResult.Error("PaymentAmount", $"Payment amount must be between {MinPaymentAmount.ToString("C0")} and {MaxPaymentAmount.ToString("C0")}"));
            }

            return(ValidatorResult.Ok());
        }