Exemplo n.º 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 :)

                hashCode = hashCode * 59 + IdReservation.GetHashCode();
                if (Car != null)
                {
                    hashCode = hashCode * 59 + Car.GetHashCode();
                }

                hashCode = hashCode * 59 + Days.GetHashCode();

                hashCode = hashCode * 59 + Price.GetHashCode();
                if (ReservationNr != null)
                {
                    hashCode = hashCode * 59 + ReservationNr.GetHashCode();
                }
                if (PickUpDate != null)
                {
                    hashCode = hashCode * 59 + PickUpDate.GetHashCode();
                }

                hashCode = hashCode * 59 + IsLease.GetHashCode();
                if (Customer != null)
                {
                    hashCode = hashCode * 59 + Customer.GetHashCode();
                }
                return(hashCode);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Returns true if Reservation instances are equal
        /// </summary>
        /// <param name="other">Instance of Reservation to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(Reservation other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     IdReservation == other.IdReservation ||

                     IdReservation.Equals(other.IdReservation)
                     ) &&
                 (
                     Car == other.Car ||
                     Car != null &&
                     Car.Equals(other.Car)
                 ) &&
                 (
                     Days == other.Days ||

                     Days.Equals(other.Days)
                 ) &&
                 (
                     Price == other.Price ||

                     Price.Equals(other.Price)
                 ) &&
                 (
                     ReservationNr == other.ReservationNr ||
                     ReservationNr != null &&
                     ReservationNr.Equals(other.ReservationNr)
                 ) &&
                 (
                     PickUpDate == other.PickUpDate ||
                     PickUpDate != null &&
                     PickUpDate.Equals(other.PickUpDate)
                 ) &&
                 (
                     IsLease == other.IsLease ||

                     IsLease.Equals(other.IsLease)
                 ) &&
                 (
                     Customer == other.Customer ||
                     Customer != null &&
                     Customer.Equals(other.Customer)
                 ));
        }